View Single Post

  #1 (permalink)  
Old 05-13-2005
Gianmaria Gianmaria is offline
Member
Yellow Belt
 
Join Date: Dec 2004
Posts: 44
getAddress(ldouble lat, double lon) (And a question with it)

Hi All,
i'm using this function.. and i wonnna share this with other members.. it seem that many have the same question.. how do i transform a lat/lon to a valid address.. here we go.. this is the function i use..

Code:
public override string getAddress(double lat, double lon)
{
	string address = "";
			

	MapPoint.FindResults results;
	MapPoint.Location mLoc = this.mMap.Location.Location;
	mLoc = this.mMap.GetLocation(lat, lon);
	results = this.mMap.ObjectsFromPoint(this.mMap.LocationToX(mLoc), this.mMap.LocationToY(mLoc));

	foreach (object o in results) 
	{ 
	     try
	     {
		MapPoint.Location Loc = (MapPoint.Location)o; 

		if (Loc != null) 
		{ 
			address +=  Loc.StreetAddress.City + " - " + Loc.StreetAddress.Street;
		}
	}
	catch(System.Exception ex)
	{
						
	}
}


   System.Diagnostics.Trace.WriteLine(address);
   return address;
}
this is c# code.. but can be easly transformned to vb.

I've got a question bout the way mappoint handles this problem to.. the result of this functions vary from map zoom in my app.. at different zoom i have different results.. for someone knows much.. is there a way to get the most precise info????

regards,
Gianmaria
Reply With Quote