我想让android后退按钮退一步并删除丢弃的标记有没有可能的方法呢?
public AddMarker(){
let image = '/assets/img/rsz_marker.png';
let marker = new google.maps.Marker({
map: this.map,
animation: google.maps.Animation.DROP,
position: this.map.getCenter()
, icon: image
});
}
platform.registerBackButtonAction(() => {
if (this.nav.canGoBack()) {
this.nav.pop();
} else {
//*remove marker?
}
});
答案 0 :(得分:1)
要从地图中删除标记,您可以使用api调用setMap()
marker.setMap(null)
传递null
将标记设置为null
有关详细信息,请参阅https://developers.google.com/maps/documentation/javascript/examples/marker-remove