geolocation - Save the current device location in one variable in jQuery -
i want save devices current location 1 variable. possible?
you can use geolocation apis current location.
http://mobile.tutsplus.com/tutorials/mobile-web-apps/html5-geolocation/
save location in variable using api have mentioned above as:
var currentlocation; //this variable store current location. jquery(window).ready(function(){ jquery("#btninit").click(initiate_geolocation); }); function initiate_geolocation() { //store current location currentlocation = navigator.geolocation.getcurrentposition(handle_geolocation_query); } function handle_geolocation_query(position){ alert('lat: ' + position.coords.latitude + ' ' + 'lon: ' + position.coords.longitude); }