You are here

simple-gmap-output.html.twig in Simple Google Maps 3.0.x

Same filename and directory in other branches
  1. 8 templates/simple-gmap-output.html.twig

Displays the Simple Google Maps formatter.

Available variables:

  • include_map: TRUE if an embedded map should be displayed.
  • include_static_map: TRUE if an embedded static map should be displayed.
  • width: Width of map.
  • height: Height of map.
  • static_scale: For use with retinal displays. Can double the width and height of static map ( possible values 1 or 2 )
  • include_link: TRUE if a link to a map should be displayed.
  • link_text: Text of link to display.
  • url_suffix: Suffix of URLs to send to Google Maps for embedded and linked maps. Contains the URL-encoded address.
  • zoom: Zoom level for embedded and linked maps.
  • address_text: Address text to display (empty if it should not be displayed).
  • map_type: Type of map to use (Google code, such as 'm' or 't').
  • 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 (used for static maps only).
  • title: A title attribute for the iframe

File

templates/simple-gmap-output.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Displays the Simple Google Maps formatter.
  5. *
  6. * Available variables:
  7. * - include_map: TRUE if an embedded map should be displayed.
  8. * - include_static_map: TRUE if an embedded static map should be displayed.
  9. * - width: Width of map.
  10. * - height: Height of map.
  11. * - static_scale: For use with retinal displays. Can double the width and
  12. * height of static map ( possible values 1 or 2 )
  13. * - include_link: TRUE if a link to a map should be displayed.
  14. * - link_text: Text of link to display.
  15. * - url_suffix: Suffix of URLs to send to Google Maps for embedded and linked
  16. * maps. Contains the URL-encoded address.
  17. * - zoom: Zoom level for embedded and linked maps.
  18. * - address_text: Address text to display (empty if it should not be
  19. * displayed).
  20. * - map_type: Type of map to use (Google code, such as 'm' or 't').
  21. * - langcode: Two-letter language code to use.
  22. * - static_map_type: Type of map to use for static map (Google code, such as
  23. * 'roadmap' or 'satellite')
  24. * - apikey: Google Maps API key (used for static maps only).
  25. * - title: A title attribute for the iframe
  26. *
  27. * @ingroup themeable
  28. */
  29. #}
  30. {% if include_map %}
  31. {% set new_map_type = 0 %}
  32. {% if map_type == 'k' %}
  33. {% set new_map_type = 1 %}
  34. {% endif %}
  35. <iframe width="{{ width }}" height="{{ height }}" title="{{ iframe_title }}" frameborder="0" style="border:0" src="https://www.google.com/maps/embed?origin=mfe&amp;pb=!1m4!2m1!1s{{ url_suffix }}!5e{{ new_map_type }}!6i{{ zoom }}!5m1!1s{{ langcode }}"></iframe>
  36. {% endif %}
  37. {% if include_static_map %}
  38. <div class="simple-gmap-static-map">
  39. <img src="https://maps.googleapis.com/maps/api/staticmap?size={{ width }}x{{ height }}&amp;scale={{ static_scale }}&amp;zoom={{ zoom }}&amp;language={{ langcode }}&amp;maptype={{ static_map_type }}&amp;markers=color:red|{{ url_suffix }}&amp;sensor=false&amp;key={{ apikey }}" />
  40. </div>
  41. {% endif %}
  42. {% if include_link %}
  43. <p class="simple-gmap-link"><a href="https://www.google.com/maps?q={{ url_suffix }}&amp;hl={{ langcode }}&amp;t={{ map_type }}&amp;z={{ zoom }}" target="_blank">{{ link_text }}</a></p>
  44. {% endif %}
  45. {% if address_text is not empty %}
  46. <p class="simple-gmap-address">{{ address_text }}</p>
  47. {% endif %}