Angular-google-maps: Wie wäre es mit 2-Wege-Bindung auf Marker lat/lng?

Erstellt am 7. Juli 2017  ·  4Kommentare  ·  Quelle: SebastianM/angular-google-maps

(Titel lesen)
PS exportAs: 'agmMarker'

stale

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(); }

Alle 4 Kommentare

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.

War diese Seite hilfreich?
0 / 5 - 0 Bewertungen

Verwandte Themen

Halynsky picture Halynsky  ·  3Kommentare

stot3 picture stot3  ·  3Kommentare

alexweber picture alexweber  ·  4Kommentare

n1t3w0lf picture n1t3w0lf  ·  3Kommentare

nthonymiller picture nthonymiller  ·  4Kommentare