HTML 5 जिओलोकेशन का उपयोग उपयोगकर्ता के स्थान का पता लगाने के लिए किया जाता है। यह एसएसएल कनेक्शन के बिना हो सकता है। इसे निम्नानुसार उत्पन्न किया जा सकता है -
// 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
}};