(leia o título)
PS exportAs: 'agmMarker'
Sou novo no Angular2 e no AGM, mas adoraria, realmente pensei que já estaria disponível.
Alguém sabe como obter lat / lng de um marcador arrastado?
@ matt-lethargic Smth assim:
<agm-marker [markerDraggable]="true"
(dragEnd)="markerMoved($event)"
[latitude]="latitude || 39.8282"
[longitude]="longitude || -98.5795"></agm-marker>
markerMoved(e) {
const geocoder = new google.maps.Geocoder();
geocoder.geocode({'location': e.coords}, (res, status) => {
if (status === google.maps.GeocoderStatus.OK && res.length) {
this.ngZone.run(() => this.setLocation(res[0]));
}
})
}
setLocation(place) {
this.latitude = place.geometry.location.lat();
this.longitude = place.geometry.location.lng();
}
<agm-marker (dragEnd)="draggEnded($event)" [markerDraggable]="true" [latitude]="tripMirror.departure?.latitude"
[longitude]="tripMirror.departure?.longitude" iconUrl="assets/icons/icon_marker_red.png"></agm-marker>
Por alguma razão, quando tento arrastá-lo, movo apenas o mapa inteiro, não consigo mover o marcador ... alguma ajuda nisso?
Este problema foi marcado automaticamente como obsoleto porque não teve atividades recentes. Ele será fechado se nenhuma outra atividade ocorrer. Obrigado por suas contribuições.
Comentários muito úteis
@ matt-lethargic Smth assim:
<agm-marker [markerDraggable]="true" (dragEnd)="markerMoved($event)" [latitude]="latitude || 39.8282" [longitude]="longitude || -98.5795"></agm-marker>
markerMoved(e) { const geocoder = new google.maps.Geocoder(); geocoder.geocode({'location': e.coords}, (res, status) => { if (status === google.maps.GeocoderStatus.OK && res.length) { this.ngZone.run(() => this.setLocation(res[0])); } }) }
setLocation(place) { this.latitude = place.geometry.location.lat(); this.longitude = place.geometry.location.lng(); }