0

I'm developing a google maps application with 50 locations/markers and expecting it to reach about 1000 in a month, each location has a separate database record with properties:

Name, Description, Latitude, Longitude, Address (Country, City, Street,..). 

To avoid problems when scaling the application I have 2 concerns:

  1. If the locations can reach up to 1000, is it advisable to fetch all the data on the page-load or only locations that fall inside the viewport bounds so that a database call happens every time the map idles (stops moving)?

  2. Should all the location-records contain the coordinate and address information or is only saving the PlaceId (Google maps Id for every location) a good alternative.

    • Pro: Working with the PlaceId will make sure that there is no unnecessary or wrong information in the database.
    • Pro: When adding a new location, users can easily use the Google Maps Place Autocomplete functionality to search for the address, example:

      enter image description here

    • Cons: Before showing the locations inside the viewport, they should be looped and for each one the Place API should get called to get the coordinate and address information using the PlaceId, only than the marker can get placed on the Map.

1
  • 1
    It depends on factors like network bandwidth, clients computational resources (especially for mobile devices), etc. As for your "cons": many databases allow you to do geolocation queries efficiently.
    – scriptin
    Commented Jul 26, 2017 at 9:50

1 Answer 1

1

i have implemented your version (1) with openstreetmap (osmdroid) on android with about 16000 locations where the places are selected from database after each zoom/move: (sql pseudocode)

 select ... from location
 where currentZoomlevel >= location.zoomLevelMin and 
       currentZoomlevel <= location.zoomLevelMax and
       currentLatMin >= location.lat and 
       currentLatMax >= location.lat and 
       currentLonMin >= location.lon and 
       currentLonMax >= location.lon

the trick is that for every zoomlevel no more that 100 locations are visible at a time.

For example if you have 100 restaurants in a city it makes no sense to show all 100 locaions of one city while zoomlevel is 1 (world-map)

on my weak android-4.2 device sql-selecting 100 locations plus adding 100 icons into the map plus redenering is done in less that 1 second

Not the answer you're looking for? Browse other questions tagged or ask your own question.