0

I need to display around 50,000 markers on the map. But i was able to plot only 10000 points. I thought of implementing this way correct me if i'm wrong... Instead of fetching whole data at once just fetch points that are in the viewport and depending on the zoomlevel.

ex:google maps: at one zoomlevel only states are shows if we zoom in further cities are shown

I'm stuck with the zoomlevel.. how to relate zoomlevel and viewport.Is there any algorithm or formulae that helps in getting the lat long values or it needs to be hardcoded in the database like for particular lat-lon this is the zoomlevel range so while fetching range is checked.

i'm using openlayers bbox feature to get the bounds

Thanx in advance

Sindhu
  • 1
  • 2

1 Answers1

0

google.maps.Map.getBounds() will return the lat/long bounds of the viewport.

50,000 markers is a lot compared to what Google Maps can handle; you would have to be way zoomed in to have few enough markers to be under the limits. You might do better by creating custom tiles with dots instead of markers. You can see an example at http://maps.webfoot.com/demos/election2008/

Scroll down to the third overlay to see dots; select zip codes to see LOTS of dots.

  • that is a great example thanx.i wont display all 50000 markers at a time i will fetch markers based upon the viewport and zoomlevel. my doubt is there any way to relate zoomlevel and lat.lon or we shud define before hand that this set of markers are displayed at this zoomlevel??? – Sindhu Mar 26 '13 at 09:21
  • There is a formula to convert from lat/lng to pixel coordinate; that has been answered many times here, e.g. http://stackoverflow.com/questions/5983099/converting-longitude-latitude-to-x-y-coordinate – Kaitlin Duck Sherwood Mar 26 '13 at 19:06
  • I would suggest that next to the points' lat/long in the database, store the pixel coordinates at some high zoom level (I use zoom level 24). Then, to find the pixel coordinate at a given zoom, you need to do one shift (to deal with the zoom), then pull off the lower eight bits for the pixel coordinate on the tile. This operation -- one shift and one bitwise AND -- is so inexpensive that you can do this in SQL *and* if you use the DISTINCT keyword,you will only get one point per pixel. I describe this at http://blog.webfoot.com/2013/03/12/optimizing-map-tile-generation/ – Kaitlin Duck Sherwood Mar 26 '13 at 19:09