Google Maps V3: Only show markers in viewport - Clear markers issue

前端 未结 6 1209
再見小時候
再見小時候 2021-01-30 04:33

I like to create a map with Google Maps that can handle large amounts of markers (over 10.000). To not slow down the map I\'ve created a XML-file that only outputs the markers t

6条回答
  •  面向向阳花
    2021-01-30 05:16

    This article goes through it pretty nicely: Dynamically loading thousands of markers in Google Maps

    • dynamically load markers until we reach a threshold
    • keep a hashtable of markers that have already been added
    • after the threshold has been reached, remove markers that aren’t currently within the viewport
    • remove all markers from the map when the user has zoomed out, and don’t load any markers until the user zooms back to a reasonable level

提交回复
热议问题