简体   繁体   中英

latitude longitude is not able to get in android?

I am not able to get Lat/Long in my code. I am using cordova-2.7.0 and I have included jquery .js files and added permissions in manifest file still it is not working please solve my issue.

I am able to enter in to if (navigator.geolocation) loop but it does not call back function showPosition(position) function.

<!DOCTYPE html>
<html xml:lang="en" lang="en">
<head>
<title>Device Properties Example</title>
<script src="jquery-1.10.2.min.js"></script>
<script src="jquery-1.10.2.js"></script>
<script type="text/javascript" charset="utf-8" src="cordova-2.7.0.js"></script>
<script>
var x=document.getElementById("demo");
function getLocation()
{
if (navigator.geolocation)
{
alert("test1");
navigator.geolocation.getCurrentPosition(showPosition);
}
else{x.innerHTML="Geolocation is not supported by this browser.";}
}
function showPosition(position)
{
alert("test2");
x.innerHTML="Latitude: " + position.coords.latitude + 
"<br>Longitude: " + position.coords.longitude;  
}
</script>
</head>
<body>
<p id="demo">Click the button to get your coordinates:</p>
<button onclick="getLocation()">Try It</button>
</body>
</html>

hey you can use arcgis for javascript to implement it in a better way.google for it.you will find lots of examples like this.

https://developers.arcgis.com/en/javascript/jssamples/routetask_basic_servicearea.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM