Center/Set Zoom of Map to cover all visible Markers?

前端 未结 4 1444
孤街浪徒
孤街浪徒 2020-11-28 17:20

I am setting multiple markers on my map and I can set statically the zoom levels and the center but what I want is, to cover all the markers and zoom as much as possible hav

4条回答
  •  萌比男神i
    2020-11-28 18:06

    There is this MarkerClusterer client side utility available for google Map as specified here on Google Map developer Articles, here is brief on what's it's usage:

    There are many approaches for doing what you asked for:

    • Grid based clustering
    • Distance based clustering
    • Viewport Marker Management
    • Fusion Tables
    • Marker Clusterer
    • MarkerManager

    You can read about them on the provided link above.

    Marker Clusterer uses Grid Based Clustering to cluster all the marker wishing the grid. Grid-based clustering works by dividing the map into squares of a certain size (the size changes at each zoom) and then grouping the markers into each grid square.

    Before Clustering

    After Clustering

    I hope this is what you were looking for & this will solve your problem :)

提交回复
热议问题