admin管理员组文章数量:1208155
I'm using this function to add a new marker (and polyline) to a map:
function addMarker(location) {
path = poly.getPath();
path.push(location);
marker = new google.maps.Marker({
position: location,
icon:'location.png',
title: poly.inKm() + ' km',
map: map
});
markersArray.push(marker);
}
How can I remove the last marker (for implementing undo)?
Best regards ...
I'm using this function to add a new marker (and polyline) to a map:
function addMarker(location) {
path = poly.getPath();
path.push(location);
marker = new google.maps.Marker({
position: location,
icon:'location.png',
title: poly.inKm() + ' km',
map: map
});
markersArray.push(marker);
}
How can I remove the last marker (for implementing undo)?
Best regards ...
Share Improve this question edited Jul 17, 2011 at 20:52 rebeliagamer 1,27817 silver badges33 bronze badges asked Jul 17, 2011 at 19:01 fillibusterfillibuster 6984 gold badges16 silver badges33 bronze badges2 Answers
Reset to default 17RemovingOverlays
markersArray[markersArray.length-1].setMap(null);
... for path:
path = poly.getPath();
path.pop();
PolylineOptions, MVCArray.
Last Marker is at the index of markersArray.length -1
so...
markersArray[markersArray.length-1].setMap(null);
本文标签: javascriptRemove marker in Google Maps Api v3Stack Overflow
版权声明:本文标题:javascript - Remove marker in Google Maps Api v3 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738732084a2109380.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论