Angular-google-maps: 标记 lat/lng 上的 2 向绑定怎么样?

创建于 2017-07-07  ·  4评论  ·  资料来源: SebastianM/angular-google-maps

(阅读标题)
PS exportAs: 'agmMarker'

stale

最有用的评论

@matt-lethargic Smth 像这样:
<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(); }

所有4条评论

我是 Angular2 和 AGM 的新手,但我会喜欢这个,真的以为它已经存在了。
有谁知道如何从拖动的标记中获取纬度/经度?

@matt-lethargic Smth 像这样:
<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>

出于某种原因,当我尝试拖动它时,我只能移动整个地图,而无法移动标记……对此有什么帮助吗?

此问题已自动标记为陈旧,因为它最近没有活动。 如果没有进一步的活动发生,它将被关闭。 感谢你的贡献。

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

vamsibassetty08 picture vamsibassetty08  ·  3评论

nthonymiller picture nthonymiller  ·  4评论

n1t3w0lf picture n1t3w0lf  ·  3评论

ChrisDevinePimss picture ChrisDevinePimss  ·  3评论

muhammad-shahzad-anjum picture muhammad-shahzad-anjum  ·  4评论