From the course: HTML5: Geolocation

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Using HTML5 geolocation with Google Maps

Using HTML5 geolocation with Google Maps - HTML Tutorial

From the course: HTML5: Geolocation

Start my 1-month free trial

Using HTML5 geolocation with Google Maps

This is a simple example using HTML5 geolocation data with the Google Maps API. In the last movie, we saw this in action in a moving vehicle. Now let's take a look at the code. This is the 01-geoLocMap.html file from the Chapter 3 folder in the exercise files, and I am just going to scroll down at the bottom here, and I will scroll down slowly for those of you who are copying it down. These things tend to start at the bottom and work their way up, at least the way that I write them, and so I am going to start at the bottom as we look at it. And down here at the bottom we have got this very, very little HTML--it's really just a div element that gets used by the Google Maps API-- and then we have window.onload function. I find this a convenient way to set up the code. It waits until the entire file is loaded, and so we make sure that we have got all of our objects loaded before we start initializing the JavaScript. The other way to do this is with an onload attribute in the body tag. I…

Contents