View Single Post

  #2 (permalink)  
Old 08-30-2005
Wilfried Wilfried is offline
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,112
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.
Reply With Quote