我在使用Ionic和Cordova框架中的Geolocation插件时遇到了问题。
我正在使用Visual Studio Community 2015,Cordova CLI版本为:4.3.0,并将org.apache.cordova.geolocation插件添加到VSC-2015中。
我的controller.js文件:
.controller('MapCtrl', function ($scope) {
function onSuccess(position) {
console.log(position.timestamp);
console.log(position.coords.latitude + " " + position.coords.longitude);
}
function onError(error) {
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
navigator.geolocation.getCurrentPosition(onSuccess, onError);
})
将谷歌地图添加到index.html中
<script src="https://maps.googleapis.com/maps/api/js?sensor=true&v=3.exp"></script>
在我的Map.html文件中添加了一张地图。
<div id="map" data-tap-disabled="true" map> </div>
问题在于我总是得到一个固定的经纬度值,即纬度为43.465187,经度为-80.522372。
这不是我正确的地理位置信息,我需要我的当前地理位置信息以经纬度表示。
请帮助我确定故障。
此外,我正在使用浏览器上的Ripple-Nexus(Galaxy)。
非常感谢任何帮助……