October 2017
Intermediate to advanced
370 pages
8h 57m
English
The previous examples have dealt with fixed locations on a map. But what if, instead, we wanted to center the map on the user's device location? This might be useful for geofencing or location-based applications, such as near-me type apps like bike- or car-sharing.
In the last example, we used the Google Maps Embed API URL directly in the src of the amp-iframe. This time we'll need to create our own page that executes the JavaScript necessary to access the browser's Geolocation API, and then center the map on that location.
We'll use the Google Maps JavaScript API instead of the Embed API this time round. Although they both use Google Maps, they work differently: with the Embed API you retrieve a map via URLs, ...
Read now
Unlock full access