此代码在IOS设备上正常工作,但是当GPS关闭时它不能用于android devince,它不会破坏成功或失败功能,它似乎不在地图上。
navigator.geolocation.getCurrentPosition(controller.geoLocationSuccess, controller.onFailGeoLocation, { enableHighAccuracy: true });
geoLocationSuccess: function (geoPosition) {
alert('success');
controller.setCoords(geoPosition);
map.addMarker({
iconSrc: "images/urhere32.png",
location: [latitude, longitude],
tooltip: {
text: title,
isShown: true
}
});
}
onFailGeoLocation: function (response, notifytype, code) {
if (response.code == 1) {
ui.alert("Şu anda bulunduğunuz noktaya göre çalıştırmak için, ayarlardan bu uygulamaya Lokasyon Servis kullanımına izin veriniz");
controller.setCoords(GeoCoords);
map.addMarker({
iconSrc: "images/urhere32.png",
location: [latitude, longitude],
tooltip: {
text: title,
isShown: true
}
});
}
}
setCoords: function (geoPosition) {
if (viewModel.accountInformations.LATITUDE != 0 && viewModel.accountInformations.LONGITUDE != 0) {
latitude = viewModel.accountInformations.LATITUDE;
longitude = viewModel.accountInformations.LONGITUDE;
title = viewModel.accountInformations.MUST_AD;
}
else {
latitude = geoPosition.coords.latitude;
longitude = geoPosition.coords.longitude;
title = "Buradasınız";
}
}
答案 0 :(得分:0)
我以这种方式解决了我的问题,如果关闭了Geolocation服务,则在超时间隔(如果指定)之后调用onError回调。如果未指定timeout参数,则不会调用回调。