DISPLAY THE USER’S CURRENT LOCATION WITH GOOGLE MAPS

Earlier in this chapter, the section “Display a Specific Location with Google Maps” discusses how to use Google Maps to display a location. After you can locate the user, as explained in the preceding section, “Request the User’s Current Location,” it is possible to inject that information directly into a Google Maps JavaScript API object.

This is useful if you want to provide an interactive map that compares the user’s current location to another location, such as a corporate office or an attraction. Although the code in this example shows how to get the user’s location and set a marker, you can modify it by repeating step 6 below — with absolute latitude and longitude coordinates — and steps ...

Get HTML5: Your visual blueprint™ for designing rich web pages and applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.