HTML5 Geolocation – Google Map with Modernizr
HTML5 defines a very handy function, which is geolocation. Basically, this function will try to locate user’s location. But at the moment, not every browser supports this function. We need to implement some tedious conditions to check whether the browser supports Geolocation or not. Luckily, there is an open source javascript library, Modernizr. Using modernizr is simple, just import a script and use it. For example, if I want to check the browser whether Geolocation is supported or not, I just write the following code
if (Modernizr.geolocation){
//...Your logic here
}
Here, I wrote a simple html page that locate your location using Geolocation and show it on the Google map.
http://just-thor.com/sample-works/geolocation.html
Happy coding.












Wow, thats neat…I didn’t know it can be so easy. Does it also provide location information in text, as in city state etc?
Hi,Modernizr is used to detect whether such functions like geolocation or local storage are supported by the browser or not…We can always use Google Geocoding Service to translate latitude and longitude into address