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

How to retrieve nearest city from longitudes and latitud

This is a discussion on How to retrieve nearest city from longitudes and latitud within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hello I have an application over Visual C++ and i need to find the nearest city to an geografic point ...

  1. #1
    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 &#40; i <=numResult&#41;
    			&#123;
    				
    				VARIANT idx;
    				VariantInit&#40; &idx &#41;;
    				V_VT&#40;&idx&#41; = VT_I4;
    				V_I4&#40;&idx&#41; = 1;
    				
    				streetLoc=streetResults.GetItem&#40; &idx &#41;;
    				
    				szLocalidad=streetLoc.GetLocation&#40;&#41;.GetName&#40;&#41;;
    
    				callejero=streetLoc.GetStreetAddress&#40;&#41;;
    							
    				i++;
    			&#125;

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

    "Crashing" does not mean muthc. Put you code into an exeption blockand reply with the exact error you have. This way we can help more.

  3. #3
    fsarraj is offline Junior Member White Belt
    Join Date
    Mar 2006
    Posts
    3
    I have done , my excepction is produced in the line
    Code:
    callejero=streetLoc.GetStreetAddress&#40;&#41;;
    and gives the following exception "menber not found".

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

    I dont think there is a GetStreetAddress method in a Location object. I think what you are looking for is the StreetAddress property, so:

    Code:
    callejero = streetLoc.StreetAddress;

  5. #5
    sush is offline Junior Member White Belt
    Join Date
    May 2011
    Posts
    1

    Re: How to retrieve nearest city from longitudes and latitud

    Hello ,

    I need java code to find nearest city for a given latitude and longitude. Or is there any class in java to find nearest city using GMT offset? Please help me. Thank you.
    Last edited by sush; 05-16-2011 at 02:59 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to retrieve complete address from longitudes and latitud
    By Learner in forum MapPoint Desktop Discussion
    Replies: 14
    Last Post: 01-04-2007, 09:40 AM
  2. Is it possible to calculate latitud/longitud through address
    By Learner in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 03-08-2006, 01:15 PM
  3. MapPoint can't import near-zero longitudes?
    By random in forum MapPoint Desktop Discussion
    Replies: 6
    Last Post: 08-25-2004, 10:03 AM
  4. nearest city of a point
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 04-07-2003, 07:46 AM
  5. How to find nearest city?
    By Petr Brant in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 08-23-2002, 02:49 PM

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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96