You are here

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

File

modules/geofield_map_extras/templates/geofield-static-google-map.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Displays the Geofield Google Map (static) formatter.
  5. *
  6. * Available variables:
  7. * - width: Width of map.
  8. * - height: Height of map.
  9. * - scale: For use with retinal displays. Can double the width and
  10. * height of static map (possible values 1, 2 or 4).
  11. * - locations: Array of Markers locations
  12. * maps. Contains the URL-encoded address.
  13. * - zoom: Zoom level for embedded and linked maps.
  14. * - langcode: Two-letter language code to use.
  15. * - static_map_type: Type of map to use for static map (Google code, such as
  16. * 'roadmap' or 'satellite').
  17. * - apikey: Google Maps API key.
  18. * - marker_color: The marker color (optional)
  19. * - marker_size: The marker size
  20. *
  21. * @ingroup themeable
  22. */
  23. #}
  24. {# Define a zoom string depending on the numer of locations. #}
  25. {% set zoom_string = locations|length > 1 ? "" : "&zoom=" ~ zoom %}
  26. <div class="geofield-static-google-map">
  27. <img src="https://maps.googleapis.com/maps/api/staticmap?size={{ width }}x{{ height }}&amp;scale={{ scale }}{{zoom_string }}&amp;language={{ langcode }}&amp;maptype={{ static_map_type }}&amp;markers=color:{{ marker_color is empty ? 'red' : '0x' ~ marker_color|trim('#')|upper }}|size:{{ marker_size }}|{{ locations|join('|') }}&amp;sensor=false&amp;key={{ apikey }}" />
  28. </div>