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

前端 未结 6 1197
再見小時候
再見小時候 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:06

    Your original function seems like a lot of code. I'd do something like this:

    if( map.getBounds().contains(markers[i].getPosition()) ) {
       myMarkerDisplayFunction(markers[i]);
    }
    

提交回复
热议问题