如何删除Dropped map marker?

时间:2017-07-07 11:06:35

标签: google-maps google-maps-api-3 ionic2 google-maps-markers

我想让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?
      }
    });

1 个答案:

答案 0 :(得分:1)

要从地图中删除标记,您可以使用api调用setMap()

marker.setMap(null)

传递null将标记设置为null

有关详细信息,请参阅https://developers.google.com/maps/documentation/javascript/examples/marker-remove