Angular-google-maps: Que tal a ligação bidirecional no marcador lat / lng?

Criado em 7 jul. 2017  ·  4Comentários  ·  Fonte: SebastianM/angular-google-maps

(leia o título)
PS exportAs: 'agmMarker'

stale

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

Todos 4 comentários

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.

Esta página foi útil?
0 / 5 - 0 avaliações

Questões relacionadas

PeterSisovsky picture PeterSisovsky  ·  3Comentários

supran2811 picture supran2811  ·  4Comentários

Halynsky picture Halynsky  ·  3Comentários

ostapch picture ostapch  ·  4Comentários

maneesht picture maneesht  ·  3Comentários