使用ng map/angularjs google maps在javascript中检索当前位置
如何使用allenhwkim提供的angularjs谷歌地图api在javascript中检索当前位置 目前,我可以通过html代码访问我的当前位置使用ng map/angularjs google maps在javascript中检索当前位置,javascript,angularjs,google-maps,Javascript,Angularjs,Google Maps,如何使用allenhwkim提供的angularjs谷歌地图api在javascript中检索当前位置 目前,我可以通过html代码访问我的当前位置 <marker animation="DROP" position="current-location"></marker> 谢谢大家! 通过空检查navigator.geolocation,还值得首先检查浏览器是否支持地理位置。看见 var options = { enableHighAc
<marker animation="DROP" position="current-location"></marker>
谢谢大家! 通过空检查navigator.geolocation,还值得首先检查浏览器是否支持地理位置。看见
var options = {
enableHighAccuracy: true
};
navigator.geolocation.getCurrentPosition(function(pos) {
$scope.position = new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude);
console.log(JSON.stringify($scope.position));
},
function(error) {
alert('Unable to get location: ' + error.message);
}, options);
$scope.currentLocation = function(){
//how do i get current location?
};
var options = {
enableHighAccuracy: true
};
navigator.geolocation.getCurrentPosition(function(pos) {
$scope.position = new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude);
console.log(JSON.stringify($scope.position));
},
function(error) {
alert('Unable to get location: ' + error.message);
}, options);