MapPoint Forums

MapForums

Community of MapPoint and Virtual Earth Users and Developers




Reverse geocoding

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 ...


Go Back   MapPoint Forums > Map Forums > MapPoint 2006/2009 Discussion

Today's Posts Twitter Feed Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read



Click here to register

Reply

 

LinkBack (9) Thread Tools Display Modes
  9 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 01-04-2007
Junior Member
Yellow Belt
 
Join Date: May 2006
Posts: 12
Send a message via ICQ to giaarcix Send a message via MSN to giaarcix
Reverse geocoding

Hello everybody,
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..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 01-04-2007
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,177
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 !
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
geocoding, reverse


LinkBacks (?)
LinkBack to this Thread: http://www.mapforums.com/reverse-geocoding-5547.html

Posted By For Type Date
An API to Control MapPoint 2006 GPS Features - Part I of II - MapPoint Articles - MP2K Magazine This thread Refback 01-12-2007 10:05 AM
What's New in Streets and Trips 2006 - MapPoint Articles - MP2K Magazine This thread Refback 01-08-2007 06:15 PM
Reverse Geocoding, Pt. III - MapPoint Articles - MP2K Magazine This thread Refback 01-08-2007 12:45 PM
Extracting the Mappoint 2002 Points of Interest - MapPoint Articles - MP2K Magazine This thread Refback 01-07-2007 04:54 AM
MapPoint Help - MP2K Magazine This thread Refback 01-06-2007 07:12 PM
Map Visitors - Powered by Virtual Earth This thread Refback 01-06-2007 11:14 AM
Using Autoroute 2003 Data in MapPoint 2002 - MapPoint Articles - MP2K Magazine This thread Refback 01-05-2007 11:30 AM
MapPoint Articles - MP2K Magazine This thread Refback 01-04-2007 02:51 PM
MP2K Update Archives - MP2K Magazine This thread Refback 01-04-2007 10:23 AM

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

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


All times are GMT -5. The time now is 05:35 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0 RC2
MP2K Magazine
Visitor Map

Corfu Holiday
Why not enjoy the option of a Corfu holiday through UlookUbook? Check out the online offers...



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59