Getting Google directionsService.route markers
I have an array of longlats (waypoints), source and destination.
I have called the method directionsService.route and displayed the route on the map successfully. I need to get the references of all the marker objects present on the map. Is there any way i can 开发者_如何学Cachieve this? Like map.getMarkers returning an array of markers on the map?
sorry it's not possible by map object but you can store the marker into the array variable
var allMarkers = [];
....
// Create some markers
for(var i = 0; i < 10; i++) {
var marker = new google.maps.Marker({...});
allMarkers.push(marker);
}
精彩评论