How to use HTML5 geolocation

The new geolocation function in HTML5 adds the functionality to the browser necessary to detect the user’s location, generate co-ordinates, and return them as values back to the user.

Not only will it work across desktops, but across mobile and tablet devices too — which opens up huge possibilities for web developers looking to create location-based online apps!

In today’s tutorial, you’ll learn how to fetch the latitude and longitude co-ordinates using nothing more than a few lines of HTML and JavaScript. You’ll then learn how to take those co-ordinates and feed them into the Google Maps API to reverse-geocode those values and produce a live in-browser map of your current location, complete with a place marker.

Once you’ve finished the tutorial, I recommend checking out the full Google Maps API documentation to learn about some of the more extensive and exciting features it’s capable of.

Have you used a location service for a project? How reliable do you think geolocation is? Let us know in the comments.

Featured image/thumbnail, location image via Shutterstock.

WDD Staff

WDD Staff

WDD staff are proud to be able to bring you this daily blog about web design and development. If there's something you think we should be talking about let us know @DesignerDepot.

Join to our thriving community of like-minded creatives!