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:
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)?
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:
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.