我正在使用 jquery mobile 开发一个 phonegap 应用程序。我没有得到当前位置。在设备上准备好 onSucess 或 onError 功能不会被触发。我想只有我没有得到位置。这是我的代码。
function onDeviceReady() {
var options = { frequency: 3000 };
watchID = navigator.geolocation.watchPosition(onSuccess, onError, options); }
function onSuccess(position){
var minZoomLevel = 6;
map = new google.maps.Map(document.getElementById('map_canvas'), {
zoom: minZoomLevel;
center: new google.maps.LatLng(position.coords.latitude,position.coords.longitude),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var marker = new google.maps.Marker({
position: new google.maps.LatLng(position.coords.latitude,position.coords.longitude),
map: map,
});
}
function onError() {
alert("Sorry,we cann't find your location");
}