cordova - phonegap geolocation does not work -


hello geolocation phonegap doesn't work me. here code.

function getgeo() {     alert("begin getgeo");     navigator.geolocation.getcurrentposition(onsuccess, onerror); }  function onsuccess(position) {     alert("onsuccess");     var test = '"lat":"' + (position.coords.latitude) + '", "long":"' + (         position.coords.longitude);     alert(test); }  function onerror(error) {     alert('code: ' + error.code + '\n' + 'messagee: ' + error.message +         '\n'); } 

i alert "begin getgeo" , nothing happens.

in config.xml file added line.

<gap:plugin name="org.apache.cordova.geolocation" version="0.3.10" /> 

try this:

navigator.geolocation.getcurrentposition(onsuccess, onerror, {maximumage:600000, timeout:5000, enablehighaccuracy: true});  function onsuccess(position) {     //lat long fetched , stored in session variables     //these variables used while storing data in local database      localstorage.setitem("lat", position.coords.latitude);     localstorage.setitem("long", position.coords.longitude); } function onerror(error) {     if (error.code == error.timeout)     {         // attempt gps loc timed out after 5 seconds,          // try low accuracy location         navigator.geolocation.getcurrentposition(                onsuccess,                 errorcallback_lowaccuracy,                {maximumage:600000, timeout:10000, enablehighaccuracy: false});         return;     }     alert("geolocation didn't worked, try reboot internet connection or device, app close now.");     navigator.app.exitapp(); }  function errorcallback_lowaccuracy(error) {     alert("geolocation didn't worked, try reboot internet connection or device, app close now.");     navigator.app.exitapp(); } 

Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -