how to get all markers on google-maps-v3

前端 未结 6 2070
南方客
南方客 2020-12-05 01:51

Is there a way to get all the markers on Google Maps?

6条回答
  •  -上瘾入骨i
    2020-12-05 02:17

    Google Maps API v3:

    I initialized Google Map and added markers to it. Later, I wanted to retrieve all markers and did it simply by accessing the map property "markers".

    var map = new GMaps({
        div: '#map',
        lat: 40.730610,
        lng: -73.935242,
    });
    
    var myMarkers = map.markers;
    

    You can loop over it and access all Marker methods listed at Google Maps Reference.

提交回复
热议问题