how to hide markers from DirectionsService's DirectionsRoute object in google maps api v3?
In google maps api v3, I think you can no longer get all the markers on the map object. I need to hide the very last marker from the DirectionsService result. I used to be able to do this in v2:
_gdir.getMarker(_gdir.getNumRoutes()).hide();
I have routes that start and end in the same place, and I need to h开发者_C百科ide the very last marker so that it does not overlay my original origin maker.
thanks.
If you can settle with hiding all of them then the DirectionsRendererOptions has an option to suppress markers.
https://developers.google.com/maps/documentation/javascript/reference#DirectionsRendererOptions
You hide/remove a marker using the setMap()
method with null
as the argument:
marker.setMap(null);
Check google docs Remove Marker. Note that the above method does not delete the marker. It simply hide/removes the marker from the map. If you want to show it again just use:
marker.setMap(map);
精彩评论