0

thats my scenario: I want to load a list of places of interest of a user based on his location (using HTML5 geolocation). But the problem is, I have a very big list of places (I don't want to have to load all places from my database), so the solution I have adopted until now is only to call mysql for the results in a given radius from the user, let's say, 1 km. But I'd like when user is dragging google maps to explore the map, load progressively the places for the area is shown on the map (basically something similar to what foursquare does).

Is there any simple way to achieve that? Hope I was clear with the question, thanks in advance, any help is appreciated.

Jesús.

  • I have read this post that was very useful: http://stackoverflow.com/questions/8850336/radius-of-40-kilometers-using-latitude-and-longitude so I used this mysql call to obtain all places in a given radius. But if user explores the map dragging with the mouse outside this radius obviusly dont see anything... so Id like to obtain coordinates progressively without load all them in the first place. – Jesús Cerezuela Zaplana Aug 17 '12 at 09:30

1 Answers1

1

General approach:

  1. get the bounds of the map and query your data base for markers that are currently in view
    • optional, add padding to the bounds so some markers are available just out of view if the map is dragged
  2. display the resulting markers
  3. when the map is moved (bounds_changed event), query your database for additional markers
  4. process through the returned markers, only adding those that are new (requires an array of existing markers and a way to determine that the existing marker and a newly downloaded marker are the same)

Searching the Google Maps API v3 group (and the Google Maps API v2 group, the concepts will apply but the code samples may not) should give you some examples.

geocodezip
  • 158,664
  • 13
  • 220
  • 245