Additional Twig & PHP Methods

In addition to all the Universal Methods available in the API, there are a few more methods that are available exclusively in Twig and PHP.

# tag(options = {})

Ends the map chain. Outputs a Twig\Markup object for use in a template.

{# Renders a map in the Twig template #}
{{ map.tag() }}

Same But Different

The tag method also exists in JavaScript, but beware that the usage is notably different.

Regardless of whether you are using Twig or PHP, this will create a new Twig\Markup object.

If you are working in Twig, you can use curly braces to output the map directly. This produces a <div> element with a carefully constructed data-dna property.


  • options (array) - Configuration options for the map container and its related JavaScript.
Option Type Default Description
api object {} Optional parameters for the Google Maps API.
assets bool true Whether to preload the necessary JavaScript assets.
init bool true Whether to automatically initialize the map via JavaScript.
callback string null JavaScript function to run after the map has loaded.

The init option allows the map to be automatically rendered via JavaScript, after the <div> element has first been loaded onto the page via Twig.

{# Suppress automatic initialization of the map #}
{{ map.tag({'init': false}) }}

Setting init to false will prevent the JavaScript init method from firing automatically. It will then be up to you to manually initialize the map in JavaScript.


  • A new Twig\Markup object. This can be output directly using Twig's curly brace syntax ({{ }}).

# getDna()

Aliased as dna property via magic method.

{% set dna = map.dna %}
{% set dna = map.getDna() %}


  • An array of data containing the complete map details. It will be used to hydrate a map's container in the DOM.