HTML 5 জিওলোকেশন ব্যবহারকারীর অবস্থান খুঁজে বের করতে ব্যবহার করা হয়। এটি 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
}};