Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps - Thousands of markers - JSON

In the following example the markers are loaded from a JSON.

If there are 20,000 markers the JSON is going to be quite big.

Is there any way to send different JSON files according to zoom level instead of sending one huge array?

http://gmaps-utility-library.googlecode.com/svn/trunk/markermanager/release/examples/weather_map.html

like image 442
Franek Avatar asked Apr 29 '09 18:04

Franek


People also ask

How many markers can Google Maps API handle?

2048 characters in URL is just under 100 GeoCode values. So, again no more than 100 markers.

How do I add multiple markers to Google Maps API?

Follow the below steps and add/show multiple markers on google maps using javascript with infowindows: Step 1 – Create HTML File For Display Multiple Markers. Step 2 – Add Google Maps API V3 in HTML. Step 3 – Implement JavaScript Function To Create Markers/Pins And Show on Google Map.


2 Answers

There's the notion of a "bounding rectangle" for a map view. The map api supplies this to you as two lat/long coordinate pairs - one for the SW corner, and one for the NE corner.

So if you have a custom data service that returns JSON points, you'll need to accept these coordinates as input, and adjust the returned dataset accordingly (most likely as a WHERE clause in your SELECT statement).

I don't have the details of getting this bounding rectangle memorized, but that's what API docs are for.

like image 63
Peter Bailey Avatar answered Sep 29 '22 11:09

Peter Bailey


There is a new library called MarketClustered that will help you

alt text
(source: googlecode.com)

Even if the data is too big, I think that will be better to feed the map will all the data, and let it do it's thing.

like image 22
Eduardo Molteni Avatar answered Sep 29 '22 12:09

Eduardo Molteni