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

How to find nearest city?

This is a discussion on How to find nearest city? within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hi all, I work with MS MapPoint 2002 under Delphi using TOleContainer. Everything works fine, but I have this problem: ...

  1. #1
    Petr Brant is offline Junior Member White Belt
    Join Date
    Aug 2002
    Posts
    1

    How to find nearest city?

    Hi all,
    I work with MS MapPoint 2002 under Delphi using TOleContainer. Everything works fine, but I have this problem: I have Lat and Long and want to search for nearest city. I need name of the city and name of the country, where it resides. I use this code:

    Code:
     Dist:= 1;
     Loc:= self.GetLocation(X, Y);
     Results:= Loc.FindNearby(Dist);
     while &#40;Results.Count = 0&#41; and &#40;Dist < CMaxDist&#41; do
     begin
      Results&#58;= Loc.FindNearby&#40;Dist&#41;;
      Dist&#58;= Dist*2;
     end;
     if Results.Count > 0 then //here I have all locations
    ...
    But in Results are Hotels, Restaurants, etc. How to obtain nearest city name?

    Thanks for all replies. Bye Petr

  2. #2
    John Meyer's Avatar
    John Meyer is offline Senior Member Blue Belt
    Join Date
    Jul 2002
    Posts
    478
    One of the problems with the FindNearby method is results are limited to the CURRENTLY VISIBLE PlaceCategory objects (Like Restaurants, Airports etc..) So even if there is/was a way to get the city from the nearest "Place" the results could not be depended on.

    A better approach might be what David is exploring (Also Delphi).

    http://www.mp2kmag.com/mappoint/disc...pic.asp?t=3187

  3. #3
    David is offline Junior Member Yellow Belt
    Join Date
    Aug 2002
    Posts
    13
    Hi Petr, as said above I am doing the same sort of thing although I am searching for the nearest road from a point so I can get a postcode.

    The Map.ObjectsFromPoint method:

    Code:
    mpResults &#58;= mpMap.ObjectsFromPoint&#40;mpMap.LocationToX&#40;mpLocation&#41;, mpMap.LocationToY&#40;mpLocation&#41;&#41;;
    The above converts the Given location to a X,Y point on the Map it then searches for any Nearby Objects, roads, places of interest, towns etc..
    "If it ain't broke don't fix it!"

  4. #4
    John Meyer's Avatar
    John Meyer is offline Senior Member Blue Belt
    Join Date
    Jul 2002
    Posts
    478

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 nearest city from longitudes and latitud
    By fsarraj in forum MapPoint Desktop Discussion
    Replies: 4
    Last Post: 05-11-2011, 02:04 AM
  2. find nearest locality
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 07-09-2003, 03:26 AM
  3. nearest city of a point
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 04-07-2003, 06:46 AM
  4. Find city which are placed to x km or miles of a place
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 12-09-2002, 07:11 AM
  5. Given a city find zip codes?
    By amanuel in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 09-21-2002, 12:32 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