October 2017
Intermediate to advanced
370 pages
8h 57m
English
First, we need to include the Google Maps API script before we can use it in a web page. The best place to put this is at the bottom of the page, just before the closing </body> tag (/ch9/geomap.html):
<script async defer src="https://maps.googleapis.com/maps/api/js?key=KEY&callback=buildMap"></script>
Note that we need to provide the API key, as well as the name of a callback function. For the callback parameter, we've passed in the value buildMap, so we'll put the map code in a function with this name.
Next, we need to provide an HTML container div for the map. This goes inside the opening <body> tag:
<div id="map"></div>
Note the id, we'll tell the Google Maps API to put the map into this div based on the id.
We can create ...
Read now
Unlock full access