Community of VE/MapPoint Users and Developers
This is a discussion on How to retrieve complete address from longitudes and latitud within the MapPoint 2006/2009 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 ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| How to retrieve complete address from longitudes and latitud 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 |
| |||
|
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) {
// ...
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
| 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 |
| |||
|
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);
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
| 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 |
| |||
|
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 |
| |||
|
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".
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
| 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. |
| |||
| 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
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
| 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. |
![]() |
| Tags |
| address, complete, latitud, longitudes, retrieve |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to retrieve nearest city from longitudes and latitud | fsarraj | MapPoint 2006/2009 Discussion | 3 | 03-08-2006 01:22 PM |
| Is it possible to calculate latitud/longitud through address | Learner | MapPoint 2006/2009 Discussion | 1 | 03-08-2006 01:15 PM |
| Complete adress, when using ShowFindDialog? | Jarun | MapPoint 2006/2009 Discussion | 3 | 04-11-2005 02:31 PM |
| MapPoint can't import near-zero longitudes? | random | MapPoint 2006/2009 Discussion | 6 | 08-25-2004 10:03 AM |
| Complete data connectivity | Anonymous | MapPoint 2006/2009 Discussion | 0 | 07-01-2003 03:57 AM |