Chaining

# What & Why

Chaining refers to the ability to run multiple commands on a map sequentially...

{% set map = googleMaps.img(locations)
    .styles(styleSet)
    .center(coords)
    .zoom(level) %}

Static & Dynamic

All the examples on this page demonstrate how Static Map methods can be chained, but it's worth noting that Dynamic Map methods can also be chained together.

# Starting a Chain

A chain must always begin with the creation of a map object. No matter how you intend to decorate your static map, it will always start the same way...

{% set map = googleMaps.img(locations, options) %}

The "map object"

Internally, the "map object" refers to a Static Map Model.

# Ending a Chain

Not all chains need to be concluded right away... you may sometimes find it helpful to keep a chain alive long enough to perform more operations on the map object. Eventually though, you'll probably want to end the chain.

To end the chain, apply either the tag method or src method to wrap it all up.

# tag

Outputs a fully-rendered <img> tag for the Twig template.

{# Renders a map #}
{{ map.tag() }}

# src

Gets only the fully-configured URL of the static map.

{# Returns the static image URL #}
<img src="{{ map.src() }}">