Retrieve Geo Location from Your browser

If you web application needs location of the user this is the code you want. But remember this is HTML 5 and won’t work with your old web browsers.

In most cases this gives the correct location of the user depends on the device capabilities. If user uses a mobile device GPS enabled this gives the exact location, but if it’s not it uses ip addresses and other signalling details to detect the location which not be very accurate.



<script type="text/javascript">

function success(pos) {
var crd = pos.coords;

console.log('Your current position is:');
console.log('Latitude : ' + crd.latitude);
console.log('Longitude: ' + crd.longitude);
console.log('More or less ' + crd.accuracy + ' meters.');
};

function error(err) {
console.warn('ERROR(' + err.code + '): ' + err.message);
};

var options = {
enableHighAccuracy: true,
timeout: 5000,
maximumAge: 0
};

navigator.geolocation.getCurrentPosition(success, error, options);

</script>


Any way that’s all folks, have fun with you location enabled web applications.

Thanks

Make Your Website Mobile Compatible

When you read the title you will be amazed can we make any website mobile compatible…? When we make our website we always consider the mobile web browsers, So we use bootrap, jquery mobile, ..etc to create mobile compatible websites.

Even you create your website compatible to mobile browsers, you will notice in your mobile website view too smaller even you can’t touch a button. The case is in default settings website views in very normal condition, since your mobile resolution is so good than your laptop, the website in mobile browser looks tiny.

Simple task you need to do to make it right. Ad below meta tag to your website header.


<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;">

That’s all folks,

Thanks