This module provides the simplest way to get a Google Map, or a link to a Google Map, displayed with your content — by address, lat,lng, or a Google Maps URL copied straight from your browser's address bar.

Requirements

  • Shortcode contrib project (3.0.x)
  • PHP 8.3+, Drupal 11.1+ or 12.x
  • Configure your input format to allow the gmap shortcode macro

Configuration

If your input format has "Convert URLs into links" enabled, it must run AFTER the
Shortcodes filter, not before. If it runs first it rewrites the address/URL you pasted before the gmap shortcode ever sees it, which can break a pasted Google Maps URL and produce a blank or wrong embedded map.

Usage

Additional parameters

Allowed parameters listed there with the default values.

  • include_map (TRUE)
  • include_link (FALSE)
  • include_text (FALSE)
  • width (100%)
  • height (300) – In pixel.
  • address ('') – ignored if the shortcode has enclosed text; the enclosed text is used
  • as the address instead.
  • zoom (19) – value from 1 (minimal) to 20 (maximal). Overrides any zoom derived from a
  • pasted Google Maps URL, see below.
  • information_bubble (TRUE)
  • link_text (t('View larger map'))
  • address_text ('') – see below for how this is derived when the address is a Google
  • Maps URL.
  • map_type (m) – The map type can be "k" or "satellite", "h" or "hybrid", "p" or
  • "terrain" and "m" as standard
  • langcode ('')
  • url_suffix ('')

Pasting a Google Maps URL

Copying the URL from your browser's address bar while viewing a place on Google Maps and pasting it as the shortcode's content is supported directly, e.g.:

[gmap]https://www.google.com/maps/place/Some+Place/@46.0659034,18.3201822,104m/data=!3m1!1e3!...[/gmap]

The raw URL is never sent to Google's map embed as-is (Google can't render its
data=!3m1!... blob, and shows "Some customised on-map content could not be displayed" if you try).

Instead the module extracts:

  • the @lat,lng pair, used as the map location
  • the place name (e.g. "Some Place"), used for address_text/the map's title when no explicit address_text is given; left blank if the URL has no place name
  • the zoom/altitude segment, converted to an approximate zoom level (a best-effort conversion, since Google doesn't document this relationship); an explicit zoom attribute always overrides it

Not supported: shortened share links (maps.app.goo.gl/..., goo.gl/maps/...) — expand the link in your browser first and copy the full address-bar URL instead. Also not supported: the

HTML generated by Google Maps' own "Share > Embed a map" feature — use the address-bar URL, not that embed code.

Credits

This module was inspired and based on the Simple Google Maps module by Jennifer Hodgdon.
Supporting organizations: 
Sponsors development and maintenance of this project.

Project information

Releases