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
Page 1 of 2 12 LastLast
Results 1 to 10 of 15

How to retrieve complete address from longitudes and latitud

This is a discussion on How to retrieve complete address from longitudes and latitud within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hi All, I'm working on a C# desktop application with MapPoint2004. I'm using ActiveX control on Europe's map. The problem ...

  1. #1
    Learner is offline Junior Member Yellow Belt
    Join Date
    Feb 2006
    Posts
    18

    How to retrieve complete address from longitudes and latitud

    Hi All,
    I'm working on a C# desktop application with MapPoint2004. I'm using ActiveX control on Europe's map. The problem is that I've the value of Longitude and Latitude for a customer and I've to retrieve country, city, state/county, street address from it. Please guide me how can I accomplish this.
    Thanks in advance
    Regards
    Learn from cradle to the grave

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

    Something like this should help you start:

    Code:
                Location loc = mp.ActiveMap.GetLocation(lat, lon, alt);
                loc.GoTo();
    
                FindResults streetResults = map.ObjectsFromPoint(map.LocationToX(loc), map.LocationToY(loc));
    
                foreach (object o in streetResults) {
                    Location streetLoc = o as Location;
                    if(streetLoc != null && streetLoc.StreetAddress != null) {
                        // ...

  3. #3
    Learner is offline Junior Member Yellow Belt
    Join Date
    Feb 2006
    Posts
    18

    Retrieving complete address from latitude and longitude...

    Hi Wilfried,
    Thanks for your consideration and reply. Would you be kind enough to suggest how to extract country, city, county/state info from street address that I'll be able to retrieve through the code snippet that you wrote.
    Thanks in advance
    Regards
    Learn from cradle to the grave

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

    The StreetAddress contains all the propreties you need, eg:

    Code:
                    if(streetLoc != null && streetLoc.StreetAddress != null) {
                        Console.WriteLine("value    " + streetLoc.StreetAddress.Value);
                        Console.WriteLine("street   " + streetLoc.StreetAddress.Street);
                        Console.WriteLine("postcode " + streetLoc.StreetAddress.PostalCode);
                        Console.WriteLine("city     " + streetLoc.StreetAddress.City);
                        Console.WriteLine("country  " + streetLoc.StreetAddress.Country);

  5. #5
    Learner is offline Junior Member Yellow Belt
    Join Date
    Feb 2006
    Posts
    18

    It did work the problem....

    Hi,
    Thank you very much wilfried for helping me to solve the problem. It really did work. Hope i'll be able to benefit from your expertise in future also.
    Regards
    Learn from cradle to the grave

  6. #6
    djlinsen is offline Junior Member White Belt
    Join Date
    Sep 2006
    Posts
    1
    I'm trying to do the same, but when a lat lon position isn't right on a street it doesn't have any streetadress information. I tried the
    findNearby() but that finds places of intrest in the neighbourhood. I just want to know the streetadress information nearest to my lat lon position. Do you have any clue how i can do that?

    Thanks

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

    Try to go higher altitude, this lowers the resolution and chance is higher you are on a road (but also on multiple roads).

    Another approach is to check where the nearest road is from the point of your position. Will work always, but take more time, specially if position is far from a digitized road.

    For the latter you can find an article over here. Please do a search on "snap to road".

  8. #8
    VC_Man is offline Member Green Belt
    Join Date
    Nov 2006
    Posts
    93

    Re: How to retrieve complete address from longitudes and latitud

    Hi Wilfried,

    Suppose I've a pushpin somewhere on the map and from the pushpin I retrieve the Location object. Is that enough to parse one streetadres from it, or do I have to add some codes to get a nearest adress? Because I've seen your example where you used altitude = 1. I don't know if that is necessary if I've already a pushpin from where I get the Location object.

    I ask this because I've a set of hundreds of pushpins, and when I select a particular pushpin, I want to see the associated adress. So I guess there is normally one adress, because my pushpins will alway be on the road and not in a parc, a playground or something else.

    So what do you think, with your huge MP experience

    Also I like to know how to check wether an object is type of Pushpin, Location, Shape etc....
    The reason I ask this, is in the eventmethod: object.SelectionChange(NewSelection, OldSelection)
    NewSelection can be Direction, Location, Pushpin, Shape, or Waypoint object on the map.
    So that's why would like to know how to know which objecttype I deal with.
    I hope somebody reply on this soon, thnx anyway
    Last edited by VC_Man; 01-03-2007 at 07:49 AM.

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

    Re: How to retrieve complete address from longitudes and latitud

    Hi,

    You have indeed a Pushpin object that has a Location property. But this Location object does not have a StreetAddress object, it will be null. So even for your existing pushpins that are on a road you have to find streetinformation separate.

    To know what kind of a type an object is you can do 2 things that comes into mind. This is C#, I dont know your langiage but it will be similar syntax:

    Code:
      if (newSelection is Shape)
          // It is a Shape
    
      Shape s = newSelection as Shape;
      if (s != null)
          // It is a Shape

  10. #10
    VC_Man is offline Member Green Belt
    Join Date
    Nov 2006
    Posts
    93

    Re: How to retrieve complete address from longitudes and latitud

    Hi Wilfried,

    Thnx 4 ur reply, so than I've to make another locationobject out of the latiude-longitude of the locationobject that I retrieved from a pushpinboject including the altitude paramter, right?

    Concerning the NewSelection/OldSelection, I'll create a new thread for it on the forum.

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to retrieve nearest city from longitudes and latitud
    By fsarraj in forum MapPoint Desktop Discussion
    Replies: 4
    Last Post: 05-11-2011, 03:04 AM
  2. Is it possible to calculate latitud/longitud through address
    By Learner in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 03-08-2006, 01:15 PM
  3. Complete adress, when using ShowFindDialog?
    By Jarun in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 04-11-2005, 02:31 PM
  4. MapPoint can't import near-zero longitudes?
    By random in forum MapPoint Desktop Discussion
    Replies: 6
    Last Post: 08-25-2004, 10:03 AM
  5. Complete data connectivity
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 07-01-2003, 03:57 AM

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 28 29 30 31 32 33 34 35 36