Displaying current latitude and longitude positions.
Not sure if this is the right place to put this or not but here goes.
I am trying to pull the current latitude and longitude position to put into a variable and use it to get directions to other predetermined positions on a map that will be used in a drop down. Currently I am just working on the first part. I know how to do the second. However when I use the HTML archive with my code nothing displays. Any help would be awesome! Code is below.
Thanks!
I am trying to pull the current latitude and longitude position to put into a variable and use it to get directions to other predetermined positions on a map that will be used in a drop down. Currently I am just working on the first part. I know how to do the second. However when I use the HTML archive with my code nothing displays. Any help would be awesome! Code is below.
Thanks!
Char
<script type="application/x-javascript">
function onPositionUpdate(position)
{
var lat = position.coords.latitude;
var lng = position.coords.longitude;
alert("Current position: " + lat + " " + lng);
}
if(navigator.geolocation)
navigator.geolocation.getCurrentPosition(onPositionUpdate);
else
alert("navigator.geolocation is not available");
</script>
Comments
http://www.merlin.freewebsitehosting.com/. Where it works the way it should. However I still only get a blank page on my phone.
I believe the problem you are seeing is due to the fact that getting the user location from inside an app requires additional permission flags to be compiled into it. These are the permissions shown when installing the app allowing the user to decide whether or not they want to allow it. These permissions are added in the Map activity (if you chose to include the location-aware option). There currently isn't any way to add custom permissions to an app.
Darryl