Smart Map

Documentation  •  Changelog


Linking to a separate Google Map page

Generating a link to a Google map page

<a href="{{ entry.myFieldHandle.googleMapUrl }}">Open in Google Maps</a>

Generating a link for directions

{# Set destination with no starting point #}
<a href="{{ entry.myFieldHandle.directionsUrl }}">Directions in Google Maps</a>

{# Automatically detect user's starting location #}
<a href="{{ entry.myFieldHandle.directionsUrl }}&amp;saddr=Current+Location">Directions in Google Maps</a>

The directionsUrl method has up to three optional parameters:

directionsUrl(destinationTitle, startingTitle, startingAddress)

destinationTitle - Title of the destination marker.

startingTitle - Title of the starting marker.

startingAddress - An instance of another Address model. A path will be calculated between the two locations.

Titles may not always appear

Depending on the browser and usage, the destinationTitle and startingTitle may or may not be utilized.

Previously, more verbose versions of these syntaxes were used. The below methods are deprecated, in favor of the methods shown above.

DEPRECATED - Simple link to Google map:

<a href="{{ craft.smartMap.linkToGoogle(entry.myFieldHandle) }}">Open in Google Maps</a>

DEPRECATED - Directions to specified address:

<a href="{{ craft.smartMap.directions(entry.myFieldHandle, entry.title) }}">Directions in Google Maps</a>