View Single Post

  #1 (permalink)  
Old 03-07-2006
fsarraj fsarraj is offline
Junior Member
White Belt
 
Join Date: Mar 2006
Posts: 3
How to retrieve nearest city from longitudes and latitud

Hello

I have an application over Visual C++ and i need to find the nearest city to an geografic point (latitud , longuitud ) . I have the following code but is crashing in the GetStreetAddress() function. Does anyone have any idea ??


Code:
CLocation loc,streetLoc;
			CFindResults streetResults;
			CStreetAddress callejero;
	
		    loc = mapa.GetLocation(lat, lon, 0);
            loc.GoTo();

            streetResults = mapa.ObjectsFromPoint(mapa.LocationToX(loc), mapa.LocationToY(loc));

			int numResult=streetResults.GetCount();
			int i=1;
			while ( i <=numResult)
			{
				
				VARIANT idx;
				VariantInit( &idx );
				V_VT(&idx) = VT_I4;
				V_I4(&idx) = 1;
				
				streetLoc=streetResults.GetItem( &idx );
				
				szLocalidad=streetLoc.GetLocation().GetName();

				callejero=streetLoc.GetStreetAddress();
							
				i++;
			}
Reply With Quote