javascript - Sencha Touch 2 remove Google map Markers -
i'm trying remove markers google map using extjs. i'm performing setcenter() operation (i need remove old center map) , want add new marker in new center.
as know, google map instance need perform getmap() on map container, i.e map.getmap()
i tried clearmarkers();, deletemarkers(); , markers = []; neither works. google map object looks weird on chrome developer tools utility, @ least me.
with addition, same problem. i'm doing that:
new google.maps.marker({ map : map.getmap(), position : new google.maps.latlng(location.lat, location.lng), title : 'drag marker new position', animation : google.maps.animation.drop, draggable : true });
any appreciated! thanks.
it's simple. remove marker map, call setmap()
method passing null
argument.
marker.setmap(null);
note above method not delete marker. removes marker map. if instead wish delete marker, should remove map, , set marker null
.
if wish manage set of markers, should create array hold markers. using array, you can call
setmap()
on each marker in array in turn when need remove markers. can delete markers removing them map , setting array's length 0, removes references markers.
find example here view example (marker-remove.html)
read more google maps tutorial - remove marker
Comments
Post a Comment