0
我在項目中使用Angular Google Maps。我沒有在tutoria中找到信息;如何使用地理位置和檢測當前用戶的位置。我如何做到這一點?如何在Angular JS谷歌地圖中使用地理定位?
我想:
$scope.getGeoLocation = function(){
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition($scope.showPosition);
} else {
console.log("Geolocation is not supported by this browser.");
}
}
$scope.showPosition = function (position) {
$scope.map.bounds = {
northeast : position.coords.latitude,
southwest: position.coords.longitude
}
$scope.map.center = {latitude: position.coords.latitude, longitude: position.coords.longitude}
console.log(position.coords.longitude);
}
,但我得到的錯誤:
Invalid map bounds for new value: {"northeast":40.409261699999995,"southwest":49.8670924}
參見:GitHub的 - ngGeolocation:https://github.com/ninjatronic/ngGeolocation –
更新的問題 – Caur
誰能幫助我? – Caur