Skip to content

Get User Location using HTML5 Geolocation

objectivehtml edited this page Sep 6, 2014 · 1 revision

Overview

Getting a user's current location and displaying it on the map is pretty simple. You have some additional options from what is shown in this example, but this will get you started. Simply instantiate the map and use the currentLocation tag with your map's id.

Example

{% set options = {
	id: 'map', 
	width: '400px', 
	height: '300px',
	options: {
		disableDoubleClickZoom: true,
		maxZoom: 10
	}
} %}

{{ craft.googleMaps.map(options) }}

{{ craft.googleMaps.currentLocation('map') }}