(read title)
P.S. exportAs: 'agmMarker'
I'm new to Angular2 and AGM, but I would love this, really thought it would have been in already.
Does anyone know how to get the lat/lng from a dragged marker??
@matt-lethargic Smth like this:
<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>
For some reason when I try to drag it I only move the entire map, I'm not able to move the marker...any help on this?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
@matt-lethargic Smth like this:
<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(); }