Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用ng map/angularjs google maps在javascript中检索当前位置_Javascript_Angularjs_Google Maps - Fatal编程技术网

使用ng map/angularjs google maps在javascript中检索当前位置

使用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

如何使用allenhwkim提供的angularjs谷歌地图api在javascript中检索当前位置

目前,我可以通过html代码访问我的当前位置

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