【发布时间】:2013-12-11 16:03:36
【问题描述】:
当我创建了一个 phonegap 项目时:一个包含三个页面的应用程序。 当您打开第三页时,它必须显示当前位置。
我已经通过 phonegap local plugin add htps://git... 添加了地理定位插件 我添加了 script 标签 和 google stylesheet 的链接。
一切都在本地完成(所以不是通过 phonegap 构建)。
每当页面打开时,它总是返回超时(无论是在模拟器还是在平板电脑上)知道我错过了什么吗?我需要对配置文件进行额外更改吗? phonegap 3.1
感谢您的帮助, 克里斯托夫
var options = {
enableHighAccuracy: true,
timeout: 20000,
maximumAge: 10000
};
$(document).on("pageshow", "#nieuweTip", function() {
navigator.geolocation.getCurrentPosition(onGeoSuccess, onGeoError, options);
});
function onGeoSuccess(position) {
lat = position.coords.latitude;
lon = position.coords.longitude;
CreateGoogleMap();
}
function CreateGoogleMap() {
var currentposition = new google.maps.LatLng(lat,lon);
var mapoptions = {
zoom:12,
center: currentposition,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map"), mapoptions);
var marker = new google.maps.Marker({
position: currentposition,
map: map
});
}
function onGeoError(error) {
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
【问题讨论】:
-
您是否在设备中启用了 GPS?
-
尝试在没有插件的情况下使用浏览器的GPS。
-
GPS 已在设备上启用并且工作正常(谷歌地图工作)。
标签: cordova geolocation