2017-10-11 70 views
0

我需要在拖動標記停在地圖離子MARKER_DRAG_END事件不工作

我加了一個GoogleMapEvent.MARKERS_END它沒有得到triggerd

 this.map.addMarker({ 
     title: 'Current Location', 
     icon: 'red', 
     animation: 'DROP', 
     position: { 
      lat: this.location.lat, 
      lng: this.location.lng, 
     }, 
     draggable: true, 
     }) 
     .then((marker) => { 
      marker.on(GoogleMapsEvent.MARKER_DRAG_END) 
      .subscribe(() => { 
       console.log('dragged'); 
      }); 
      marker.on(GoogleMapsEvent.MARKER_CLICK) 
      .subscribe(() => { 

       alert('clicked'); 
      }); 
     }); 

回答

0

這是解決何時打印拖累使用

this.map = this.googleMaps.create(this.mapElement, mapOptions); 

創建地圖

0
  this.map.on(GoogleMapsEvent.MAP_DRAG).subscribe(
      () => { 
       let pos = this.map.getCameraTarget(); 
       this.marker.setPosition(pos); 
       });