【发布时间】:2018-01-30 11:56:46
【问题描述】:
我正在使用 AGM(角度谷歌地图)来获取地图内容。我放了一个 getCurrentLocation 按钮,它返回当前位置的纬度和经度。我可以将标记更新到那个地方,但是我的地图没有导航到那个特定的位置。这是我的示例代码。
getCurrentLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition((response) => {
this.setPosition(response);
}, function () {
alert("Unable to get the GPS location");
}, { maximumAge: 60000, timeout: 5000, enableHighAccuracy: true });
};
}
这是我的 setPosition 方法
setPosition(position: Position) {
this.marker.lat = position.coords.latitude;
this.marker.lng = position.coords.longitude;
//What to do here to move screen to this marker position
}
【问题讨论】:
标签: angular google-maps angular2-services