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 3 of 3

Getting a Postal Sector from Latitude and Longitude

This is a discussion on Getting a Postal Sector from Latitude and Longitude within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hi I have ONLY the Longitude and Latitude of a place and I need a way to find the PostalCode ...

  1. #1
    Yazzy is offline Junior Member Yellow Belt
    Join Date
    Dec 2004
    Posts
    25

    Getting a Postal Sector from Latitude and Longitude

    Hi

    I have ONLY the Longitude and Latitude of a place and I need a way to find the PostalCode for the place. No dataset avaiable

    For example Lat = 52.0185 Long = -0.2654
    Set objLoc = objmap.GetLocation(Latitude, Longitude)
    objLoc.GoTo

    Set objPin = objmap.AddPushpin(objLoc)
    objPin.Select

    I get the pushpin at the correct place on the map. But when I use the

    Set objResults = objmap.ObjectsFromPoint(objmap.LocationToX(objLocA ), objmap.LocationToY(objLocA))

    For Each objResult In objResults
    MsgBox objResult.Name
    Next

    I get incorrect results i.e 'Luton', Sandy Roundabout etc when the correct results should be Chase Hill Road, Arlesey, SG15 6.

    When I fire a MouseDown event around the pushpin I do get House Number, Chase Hill Road, Arlesey, SG15 6.

    i would like to know how I can capture this without firing MouseDown events.

    Thanks in advance

    PS
    I have also tried the following method and I get errors of 'Type Mismatch' Or 'Object does not support this method etc

    Map map = MP.ActiveMap;
    Location loc = map.GetLocation(lat, lon, 1);
    FindResults nearby = loc.FindNearby(1);
    foreach (object o in nearby) {
    loc = o as Location;
    if (loc != null && loc.StreetAddress != null && loc.StreetAddress.PostalCode != "") {
    return loc.StreetAddress.PostalCode;

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

    I just tryed this exact code in a menu item and it gives me a post code:

    Code:
            private void postcodefromlatlongToolStripMenuItem_Click(object sender, EventArgs e)
            {
                Map map = MP.ActiveMap;
                Location loc = map.GetLocation(51, 4, 1);
                FindResults nearby = loc.FindNearby(5);
                foreach (object o in nearby) {
                    loc = o as Location;
                    if (loc != null && loc.StreetAddress != null && loc.StreetAddress.PostalCode != "")
                        Console.WriteLine(loc.StreetAddress.PostalCode);
                }
            }
    FindNearby does not find always a postcode. This is because it is designed to search for points of interest which does not nececary have a postal code. Another way is scan the map in code with a vector until you have a postal code.

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

    I tryed your original code as whell and it works. Only your coordinates are not right, it has to be: loc = map.GetLocation(52.0185, -0.2653, 1);

    Longitude -0.2654 is not on a road, so map cannot give you information. You have to be at least on a known object.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to get latitude and longitude
    By ma2005pp in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 09-28-2005, 02:57 AM
  2. Latitude and Longitude
    By virgilar in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 03-21-2005, 02:01 PM
  3. Latitude and Longitude
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 11-25-2003, 01:52 PM
  4. NMEA latitude/longitude and mappoint latitude/longitude
    By muurman in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 11-22-2003, 05:42 AM
  5. VB6 - Latitude and longitude of a pushpin ???
    By Vincent BENNER in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 11-12-2002, 07:03 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