Я работаю с HTML/JavaScript-приложением, которое считывает gps-координаты с устройства. Проблема, которую я имею, что я получаю следующее сообщение об ошибке:Ошибка JavaScript-геолокации - ошибка функции обратного вызова
Uncaught TypeError: Failed to execute 'getCurrentPosition' on 'Geolocation': The callback provided as parameter 1 is not a function.
Вот JavaScript:
var app = {
position: null,
// Application Constructor
initialize: function() {
alert("app.initialize invoked");
console.log("Initializing google map");
$(document).ready(this.onDeviceReady);
},
// Execute on success - when calling this function invoke with this. prefixed
onSuccess: function()
{
alert("app.onSuccess invoked");
var lat = geolocation.coords.latitude;
var lng = geolocation.coords.longitude;
localStorage.setItem("Latitude", lat);
localStorage.setItem("Longitude", lng);
alert("lat: " + lat + "long: " + lng);
},
// Execute on failure - when calling this function invoke with this. prefixed
onError: function()
{
alert("Code: " + error.message);
},
// Execute on deviceReady - when calling this function invoke with this. prefixed
onDeviceReady: function()
{
alert("app.onDeviceReady invoked");
var options = { enableHighAccuracy: true };
alert("app.onDeviceReady invoked +2");
//<------------------- vv Does not work vvv -------------------
navigator.geolocation.watchPosition(this.onSuccess, this.onError, options);
alert("app.onDeviceReady invoked +3");
},
// Attach google map to div
showGoogleMap: function()
{
}
};
function onLoad() {
alert("onLoad invoked");
app.initialize();
}
Так что не любит так, как я регистрирующий функцию обратного вызова - this.onSuccess , Как мне это исправить? Есть идеи?
Благодаря