【发布时间】:2015-12-10 07:31:49
【问题描述】:
我在使用带有 Ionic 和 Cordova 框架的 Geolocation 插件时遇到问题。
使用 Visual Studio Community 2015,使用 Cordova CLI 版本:4.3.0 并将 org.apache.cordova.geolocation 插件添加到 VSC-2015
我的控制器.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>
问题是我总是得到一个固定的 Lat/Long 值 即纬度 = 43.465187 和经度 = -80.522372
这不是我正确的纬度/经度地理位置。我需要我当前的纬度/经度地理位置
请帮我找出故障。
我也在浏览器上使用 Ripple -Nexus (Galaxy)。
感谢任何帮助... 谢谢,
【问题讨论】:
-
你可以在移动设备上尝试,而不是使用模拟器
标签: geolocation ionic-framework ionic cordova-plugins visual-studio-cordova