geofield-static-google-map.html.twig in Geofield Map 8.2
Displays the Geofield Google Map (static) formatter.
Available variables:
- width: Width of map.
- height: Height of map.
- scale: For use with retinal displays. Can double the width and height of static map (possible values 1, 2 or 4).
- locations: Array of Markers locations maps. Contains the URL-encoded address.
- zoom: Zoom level for embedded and linked maps.
- langcode: Two-letter language code to use.
- static_map_type: Type of map to use for static map (Google code, such as 'roadmap' or 'satellite').
- apikey: Google Maps API key.
- marker_color: The marker color (optional)
- marker_size: The marker size
1 theme call to geofield-static-google-map.html.twig
- GeofieldGoogleStaticMapFormatter::viewElements in modules/
geofield_map_extras/ src/ Plugin/ Field/ FieldFormatter/ GeofieldGoogleStaticMapFormatter.php - Builds a renderable array for a field value.
File
modules/geofield_map_extras/templates/geofield-static-google-map.html.twigView source
- {#
- /**
- * @file
- * Displays the Geofield Google Map (static) formatter.
- *
- * Available variables:
- * - width: Width of map.
- * - height: Height of map.
- * - scale: For use with retinal displays. Can double the width and
- * height of static map (possible values 1, 2 or 4).
- * - locations: Array of Markers locations
- * maps. Contains the URL-encoded address.
- * - zoom: Zoom level for embedded and linked maps.
- * - langcode: Two-letter language code to use.
- * - static_map_type: Type of map to use for static map (Google code, such as
- * 'roadmap' or 'satellite').
- * - apikey: Google Maps API key.
- * - marker_color: The marker color (optional)
- * - marker_size: The marker size
- *
- * @ingroup themeable
- */
- #}
- {# Define a zoom string depending on the numer of locations. #}
- {% set zoom_string = locations|length > 1 ? "" : "&zoom=" ~ zoom %}
- <div class="geofield-static-google-map">
- <img src="https://maps.googleapis.com/maps/api/staticmap?size={{ width }}x{{ height }}&scale={{ scale }}{{zoom_string }}&language={{ langcode }}&maptype={{ static_map_type }}&markers=color:{{ marker_color is empty ? 'red' : '0x' ~ marker_color|trim('#')|upper }}|size:{{ marker_size }}|{{ locations|join('|') }}&sensor=false&key={{ apikey }}" />
- </div>