simple-gmap-output.html.twig in Simple Google Maps 3.0.x
Same filename and directory in other branches
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
1 theme call to simple-gmap-output.html.twig
- SimpleGMapFormatter::viewElements in src/
Plugin/ Field/ FieldFormatter/ SimpleGMapFormatter.php - Builds a renderable array for a field value.
File
templates/simple-gmap-output.html.twigView source
- {#
- /**
- * @file
- * 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
- *
- * @ingroup themeable
- */
- #}
- {% if include_map %}
- {% set new_map_type = 0 %}
- {% if map_type == 'k' %}
- {% set new_map_type = 1 %}
- {% endif %}
- <iframe width="{{ width }}" height="{{ height }}" title="{{ iframe_title }}" frameborder="0" style="border:0" src="https://www.google.com/maps/embed?origin=mfe&pb=!1m4!2m1!1s{{ url_suffix }}!5e{{ new_map_type }}!6i{{ zoom }}!5m1!1s{{ langcode }}"></iframe>
- {% endif %}
- {% if include_static_map %}
- <div class="simple-gmap-static-map">
- <img src="https://maps.googleapis.com/maps/api/staticmap?size={{ width }}x{{ height }}&scale={{ static_scale }}&zoom={{ zoom }}&language={{ langcode }}&maptype={{ static_map_type }}&markers=color:red|{{ url_suffix }}&sensor=false&key={{ apikey }}" />
- </div>
- {% endif %}
- {% if include_link %}
- <p class="simple-gmap-link"><a href="https://www.google.com/maps?q={{ url_suffix }}&hl={{ langcode }}&t={{ map_type }}&z={{ zoom }}" target="_blank">{{ link_text }}</a></p>
- {% endif %}
- {% if address_text is not empty %}
- <p class="simple-gmap-address">{{ address_text }}</p>
- {% endif %}