Community of VE/MapPoint Users and Developers
This is a discussion on Lat/Long of my Postal Code within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; Hello guys, it is possible to get Lat/Long of an Postal Code? I found this: http://www.mp2kmag.com/articles.asp?ArticleID=9 But why must show ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| Lat/Long of my Postal Code it is possible to get Lat/Long of an Postal Code? I found this: http://www.mp2kmag.com/articles.asp?ArticleID=9 But why must show the Find Form from Mappoint? Is it possible to make it with this code? Set oPushA = oMap.FindAddressResults(Street, City, , , PLZ) |
| |||
|
Hi, Yes, FindAddressResults give you a collection of Location objects. To get the lat / long you have to write some code yourself. Check also this article http://www.mp2kmag.com/articles.asp?...xtract.lat.lon to find out.
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
|
Hi, No what you get in the results is a collection of Location objects. They do not contain the coordinates, but the article shows you an easy method of getting the coordinates from out of a Location object.
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
|
But when I make an Function I must have an Parameter dblLat and dblLon. Is this correct or what make i wrong? ' Compute latitude and longitude given a location object ' Author: Gilles Kohl ' (gilles@compuserve.com) ' ' This code is copyrighted freeware - use freely, but please leave this ' header intact. Suggestions and comments welcome. Function Arccos(x As Double) As Double If x = 1 Then Arccos = 0 Exit Function End If Arccos = Atn(-x / Sqr(-x * x + 1)) + 2 * Atn(1) End Function Public Function CalcPos(objMap As MapPoint.map, locX As MapPoint.Location, dblLat As Double, dblLon As Double) Static locNorthPole As MapPoint.Location Static locSantaCruz As MapPoint.Location ' Center of western hemisphere Static dblHalfEarth As Double ' Half circumference of the earth (as a sphere) Static dblQuarterEarth As Double ' Quarter circumference of the earth (as a sphere) Static Pi As Double ' Check if initialization already done If locNorthPole Is Nothing Then Set locNorthPole = objMap.GetLocation(90, 0) Set locSantaCruz = objMap.GetLocation(0, -90) ' Compute distance between north and south poles == half earth circumference dblHalfEarth = objMap.Distance(locNorthPole, objMap.GetLocation(-90, 0)) ' Quarter of that is the max distance a point may be away from locSantaCruz and still be in western hemisphere dblQuarterEarth = dblHalfEarth / 2 Pi = 3.14159265358979 End If ' Compute latitude from distance to north pole dblLat = 90 - 180 * objMap.Distance(locNorthPole, locX) / dblHalfEarth Dim l As Double Dim d As Double ' Compute great circle distance to locX from point on Greenwich meridian and computed Latitude d = objMap.Distance(objMap.GetLocation(dblLat, 0), locX) ' convert latitude to radian l = (dblLat / 180) * Pi ' Compute Longitude from great circle distance dblLon = 180 * Arccos((Cos((d * 2 * Pi) / (2 * dblHalfEarth)) - Sin(l) * Sin(l)) / (Cos(l) * Cos(l))) / Pi ' Correct longitude sign if located in western hemisphere If objMap.Distance(locSantaCruz, locX) < dblQuarterEarth Then dblLon = -dblLon End Function |
| |||
|
Hi, Quote:
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| ||||
|
Wil is right... The way Gilles wrote the routine is for the values of dblLat and dblLong to be passed back out of the subroutine. In VB6 the routine works great. In .net in addition to all the syntax changes you have to pass the two lat long varaibles "ByRef" so the routine has access to change them. This is all explained by Gilles here: http://www.mp2kmag.com/a66--location....mappoint.html Good luck, Ciao,
__________________ Calv1ns |
![]() |
| Tags |
| code, lat or long, postal |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Office Interface, Lat & Long, Canada & Mexico Postal | The Lone Turtle | Wish List | 0 | 11-13-2005 08:12 AM |
| POSTAL CODE????? | Anonymous | Wish List | 0 | 02-12-2005 06:01 AM |
| Postal Code | Anonymous | MapPoint 2006/2009 Discussion | 1 | 10-14-2004 04:08 PM |
| How to get a postal code | huelsi | MapPoint 2006/2009 Discussion | 0 | 07-27-2003 01:00 PM |
| need postal code! | Anonymous | Wish List | 0 | 07-22-2003 05:47 AM |