-
Notifications
You must be signed in to change notification settings - Fork 19
Static Maps
Justin Kimbrell edited this page Aug 16, 2014
·
1 revision
At times you may wish to generate a static map (an image) instead of a map rendered with JavaScript. Static maps can be generated by passing a GoogleMaps_MapDataModel
object to the craft.googleMaps.staticMap()
method. A GoogleMaps_MapDataModel
object is returned by the field type, so it's real easy to generate static maps to from entries. If you aren't using the field type or want to manually generate a static map, you may instantiate a GoogleMaps_MapDataModel
object using the craft.googleMaps.mapDataModel()
method.
{% set data = craft.googleMaps.mapDataModel({
markers: [{
address: 'Yosemite National Park'
}, {
address: 'Yellow Stone National Park'
}]
}) %}
{{ craft.googleMaps.staticMap(data, {width: 300, height: 200}) }}
map
is the name of the Google Maps field type.
{% for entry in craft.entries.section('news') %}
{{ craft.googleMaps.staticMap(entry.map, {width: 300, height: 200}) }}
{% endfor %}