Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 2 of 2

Reverse geocoding

This is a discussion on Reverse geocoding within the MapPoint Desktop 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 ...

  1. #1
    giaarcix is offline Junior Member Yellow Belt
    Join Date
    May 2006
    Posts
    13

    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
    Last edited by Wilfried; 01-04-2007 at 01:06 PM.
    Bisogna sognare, insistere, ripetere, finchŔ il sogno si trasformi in realtÓ

  2. #2
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    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 !

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. reverse geocoding
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 07-09-2004, 07:27 AM
  2. Reverse GeoCoding
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 04-16-2004, 11:56 AM
  3. reverse geocoding
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 01-26-2004, 11:15 PM
  4. Reverse Geocoding
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 01-26-2004, 01:30 PM
  5. Reverse geocoding
    By Anonymous in forum Products: Pushpin Tool, Single State Mapper
    Replies: 0
    Last Post: 01-26-2004, 12:23 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


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