8
Làm cách nào để chuyển một hoặc nhiều tham số cho một cuộc gọi thành công khi gọi navigator.geolocation.getcurrentPosition
?Làm cách nào để truyền tham số đến thành công getCurrentPosition gọi lại?
Làm cách nào tôi có thể vượt qua deviceready
từ phương thức foundLoc
đến getGeoLoc
?
var app = {
onDeviceReady: function() {
alert = window.alert || navigator.notification.alert;
app.getGeoLoc('deviceready');
},
getGeoLoc: function (id) {
navigator.geolocation.getCurrentPosition(this.foundLoc, this.noLoc, { timeout: 3 });
},
foundLoc: function (position) {
var parentElement = document.getElementById('deviceready');
var lat = parentElement.querySelector('#lat');
var long = parentElement.querySelector('#long');
lat.innerHTML = position.coords.latitude;
long.innerHTML = position.coords.longitude;
},
noLoc: function() {
alert('device has no GPS or access is denied.');
}
};
Tôi tình cờ gặp nó và nó chắc chắn đã giúp ích. +1 cho bạn :) –