Angular google地图agm标记拖动结束事件未返回坐标
<agm-map [latitude]="latitude" [longitude]="longitude" [zoom]="zoom">
<agm-marker [latitude]="latitude" [longitude]="longitude" [markerDraggable]="true"
(dragEnd)="markerDragEnd($event)"></agm-marker>
</agm-map>
markerDragEnd($event: any) {
console.log($event);
this.latitude = $event.coords.lat;
this.longitude = $event.coords.lng;
this.getAddress(this.latitude, this.longitude);
}发布于 2021-05-11 20:07:25
我认为在Angular的新版本中,为了获得你想要的坐标,你必须这样做:
$event.latLng.lat()因此,在您的示例中,函数markerDragEnd应该如下所示:
markerDragEnd($event: any) {
console.log('lat', $event.latLng.lat()); //to see the latitude in the console
console.log('lng', $event.latLng.lng()); // to see the longitude in the console
this.latitude = $event.latLng.lat();
this.longitude = $event.latLng.lng();
this.getAddress(this.latitude, this.longitude);
}https://stackoverflow.com/questions/66455858
复制相似问题