Nowadays location-aware applications are everywhere, with advent of HTML5 and support for it all major web browsers it has become very easy to grab a user's Geo-location and use it to display customized content or display a map or whatever you can imagine to do with it.

Earlier IP was the only source of getting Geo-location information of a user, which needed additional server side scripts and extra call to the server, with HTML5 everything can be done on the client end.

Let's move ahead and see how to implement it.

Getting User's Geo-Location

W3C has developed APIs which allow any device (like your Android phone, iPhone, etc.) or you desktop/laptop browser to fetch the Geo-location of the user on the client side itself, and as a matter of fact all popular browsers' relatively new version support the Geo-location APIs.

In the following example we'll see a demo page where the user's location will be fetched when a button is clicked.