(Titel lesen)
PS exportAs: 'agmMarker'
Ich bin neu bei Angular2 und AGM, aber ich würde das lieben, dachte wirklich, es wäre schon drin.
Weiß jemand, wie man die Lat/Lng von einem gezogenen Marker bekommt??
@matt-lethargic Smth so:
<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>
Wenn ich versuche, sie zu ziehen, verschiebe ich aus irgendeinem Grund nur die gesamte Karte, ich kann den Marker nicht verschieben ... irgendeine Hilfe dazu?
Dieses Problem wurde automatisch als veraltet markiert, da es in letzter Zeit keine Aktivität hatte. Es wird geschlossen, wenn keine weitere Aktivität stattfindet. Vielen Dank für Ihre Beiträge.
Hilfreichster Kommentar
@matt-lethargic Smth so:
<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(); }