HTML5 জিওলোকেশন ব্যবহারকারীর লোকেশন বের করতে ব্যবহৃত হয়। এটি SSL কানেকশন ছাড়াও সম্ভব। এটি নিচের মত করে জেনারেট করা যায়:
// Variable apigeo shows successful location: var apigeo = function(position) { alert("API geolocation success!\n\nlat = " + position.coords.latitude + "\nlng = " + position.coords.longitude); }; var tryapigeo = function() { jQuery.post( "check the location on google map", function(success) { apiGeolocationSuccess({coords: {latitude: success.location.lat, longitude: success.location.lng}}); }) //Gives success on given geolocation .failure(function(err) { //On failure, alert with failure is shown alert("error while showing geolocation! \n\n"+err); }); };
তারপর এরর কোডের জন্য ভিন্ন-भিন্ন সвиচ কেস জেনারেট করা যায়, ভিন্ন এররের জন্য ভিন্ন এরর কোড।
var tryloc = function() {//tryloc variable show current position if (navigator.geolocation) { navigator.geolocation.getCurrentPosition( browserGeolocationSuccess, browserGeolocationFail,{ maximumAge: 70000, timeout: 40000, enableHighAccuracy: true}); / /this will show result with high accuracy }};