Community of MapPoint and Virtual Earth Users and Developers
This is a discussion on Reverse geocoding within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; Hello everybody, I've read alot about reverse geocoding and I've found that many people is still asking how to translate ...
| |||||||
| Today's Posts | Twitter Feed | Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| Reverse geocoding I've read alot about reverse geocoding and I've found that many people is still asking how to translate lat and lon values to an address. I think it's so strange that Mappoint doesn't have a simple way to do that! However I've tried to write some code in visual basic and I'd like to share it with everybody. Maybe it can be improved or somebody can tell me if I'm doing something wrong. I have tried it with Mappoint Europe 2004 and 2006 and it works fine. Actually I use it for a security and logistic application at my work. Bye bye, Giacomo from Italy Code: Public Function find_address(lat As Double, lon As Double, objMap As MapPointctl.Map, pushpin_name As Variant, iteration As Integer) As String
Dim objLoc As MapPointctl.Location
Dim objResults As MapPointctl.FindResults
Dim objpushpin As MapPointctl.Pushpin
vect1 = Array(0, 1, 1, 0, -1, -1, -1, 0, 1, 2, 2)
vect2 = Array(0, 0, 1, 1, 1, 0, -1, -1, -1, -1, 0)
If iteration = 11 Then GoTo fine
Set objLoc = objMap.GetLocation(lat + vect1(iteration) / 300, lon + vect2(iteration) / 300, 10)
Set objResults = objMap.ObjectsFromPoint(objMap.LocationToX(objLoc.Location), objMap.LocationToY(objLoc.Location))
Set objpushpin = objMap.FindPushpin(pushpin_name)
If (pushpin_name <> " ") Then
Set objpushpin = objMap.AddPushpin(objLoc)
objpushpin.Symbol = 82
objpushpin.Highlight = True
objpushpin.Name = pushpin_name
objpushpin.BalloonState = 1
End If
' FIND THE ADDRESS
For Each oObj In objResults
If oObj Is Nothing = False Then
If TypeOf oObj Is MapPointctl.Location Then
Set objLoc = oObj
If objLoc.StreetAddress Is Nothing = False Then luogo = objLoc.StreetAddress
If luogo <> "" Then
find_address = luogo
Exit Function
End If
End If
End If
Next oObj
' IF I DON'T FIND ANYTHING I ITERATE
iteration = iteration + 1
If luogo = "" Then
Call find_address(lat, lon, objMap, " ", iteration)
End If
fine:
' IF I STILL HAVEN'T FOUND ANYTHING AFTER ALL ITERATIONS I TAKE ALL I'VE GOT
If luogo = "" Then
Set objLoc = objMap.GetLocation(Val(lat) + vect1(10) / 300, Val(lon) + vect2(10) / 300)
Set objResults = objMap.ObjectsFromPoint(objMap.LocationToX(objLoc.Location), objMap.LocationToY(objLoc.Location))
For Each oObj In objResults
If Val(oObj.Name) > 0 Then
Else
If Len(RTrim(luogo)) > 2 Then
luogo = luogo + " - " + oObj.Name
Else
luogo = oObj.Name
End If
End If
Next oObj
End If
find_address = luogo
End Function
__________________ Bisogna sognare, insistere, ripetere, finchè il sogno si trasformi in realtà Last edited by Wilfried; 01-04-2007 at 12:06 PM.. |
| |||
| Re: Reverse geocoding
Hi Giacomo, thank very mutch for sharing. This benefit others too. I also did edit your post (without your permission) and put the code in between [ code ] [/ code ] tag because this is easyer for copy and more readable. thanks again !
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
![]() |
| Tags |
| geocoding, reverse |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| reverse geocoding | Anonymous | MapPoint 2006/2009 Discussion | 3 | 07-09-2004 06:27 AM |
| Reverse GeoCoding | Anonymous | MapPoint 2006/2009 Discussion | 1 | 04-16-2004 10:56 AM |
| reverse geocoding | Anonymous | MapPoint 2006/2009 Discussion | 1 | 01-26-2004 10:15 PM |
| Reverse Geocoding | Anonymous | MapPoint 2006/2009 Discussion | 1 | 01-26-2004 12:30 PM |
| Reverse geocoding | Anonymous | Products: Pushpin Tool, Single State Mapper | 0 | 01-26-2004 11:23 AM |
Corfu Holiday
Why not enjoy the option of a Corfu holiday through UlookUbook? Check out the online offers...