Geolocation in web browsers to find location & Google Maps Route examples
More and more services around us focus on where we physically are located at the moment, and how we can be assisted in the best fashion depending on that. Today I’d like to introduce the geolocation possibilities we developers have, and also play around a little with Google maps. Introducing geolocation Geolocation, i.e. finding out where someone is located, is extremely simple for a web developer. This is the code to accomplish that: 1. // Check for geolocation support 2. if (navigator.geolocation) { 3. // Use method getCurrentPosition to get coordinates 4. navigator.geolocation.getCurrentPosition( function (position) { 5. // Access them accordingly 6. alert(position.coords.latitude + ", " + position.coords.longitude); 7. }); 8. } That’s it! Pretty simple, right? What happens when you utilize this code is that the web browser will show a notification to the end user, ask them if they want to share their location or not, and offer them...