The {smartmap} Shortcode
Most of this plugin's job is to block maps. The {smartmap} shortcode does the opposite — it creates a Google Map from a plain address or coordinate pair, already wrapped in the consent placeholder. Because the plugin generates the markup itself, a shortcode map is GDPR-compliant by construction and never needs to be caught by the detection patterns.
Enable and set defaults for the shortcode in the Shortcode configuration tab.

Basic Usage
Place the shortcode anywhere content is rendered — an article, a custom-HTML module, or a third-party module that outputs to the page:
{smartmap address="Brandenburg Gate, Berlin"}
Before consent it renders as a placeholder card; after the visitor accepts, the map appears using the default zoom, type, width, and height from the Shortcode tab.
Locating the Map
Provide either an address or a latitude/longitude pair. If both lat and lng are present and numeric, the coordinates take precedence over address.
{smartmap address="Eiffel Tower, Paris"}
{smartmap lat="48.8584" lng="2.2945"}
Attribute Reference
| Attribute | Values | Default | Notes |
|---|---|---|---|
address |
Any place or address string | — | Used unless lat+lng are both set |
lat |
Decimal latitude | — | Must be paired with lng; overrides address |
lng |
Decimal longitude | — | Must be paired with lat; overrides address |
zoom |
1–21 | Tab default (14) | Clamped to the 1–21 range |
maptype |
roadmap, satellite, terrain, hybrid |
Tab default (roadmap) | Invalid values fall back to the default |
width |
NN% or NNpx |
Tab default (100%) |
Anything else falls back to the default |
height |
NNpx or NN% |
Tab default (400px) |
Anything else falls back to the default |
caption |
Any text | — | Optional caption shown with the map |
directions |
1/true/yes/on |
Tab default (off) | Adds a "Get directions" link to Google Maps |
Attribute values may be wrapped in double quotes, single quotes, or left unquoted (if they contain no spaces). The parser also repairs curly quotes and HTML entities that a content editor may have introduced, so values keep working even after the editor mangles them.
Examples
{smartmap address="Sydney Opera House" zoom="17" maptype="satellite"}
{smartmap address="Times Square, New York" width="600px" height="350" directions="yes"}
{smartmap lat="51.5007" lng="-0.1246" caption="Big Ben" zoom="16"}
Keyless vs Embed API
The shortcode builds the iframe URL one of two ways, chosen by the Embed Method selector in the Shortcode tab (Keyless or Google Maps Embed API). The API-key field appears only when you pick the Embed API:
| Keyless (no key) | With API key | |
|---|---|---|
| URL form | maps.google.com/maps?q=…&output=embed |
www.google.com/maps/embed/v1/place?key=… |
| Setup | None — works immediately | Google Cloud project + Embed API key |
| Map types | All four supported | /place supports roadmap & satellite only — terrain falls back to roadmap, hybrid to satellite |
| Best for | Quick maps, low traffic | Production sites, higher volume |
Either way, the map only loads from Google after the visitor consents. If you choose the Embed API but leave the key empty, the keyless embed is used.
"Get Directions" Link
When directions is on (per-shortcode or via the tab default), the map includes a link to:
https://www.google.com/maps/dir/?api=1&destination={your address or coordinates}
It opens turn-by-turn directions to the location in a new tab.
How It's Consent-Wrapped
The shortcode is expanded during onAfterRender. The plugin renders one of three states depending on consent:
- No decision yet — a consent placeholder card (the same
tmpl/placeholder.phpused for the inline position) - Accepted — the real Google Maps iframe (
tmpl/map.php) - Declined — a short decline notice in place of the map
Because the plugin controls all three renders, a {smartmap} map is never sent to the browser before consent.
Where Shortcodes Are Not Expanded
The plugin leaves {smartmap} text untouched in places where a map would be wrong or harmful:
- the page
<head>, such as the title and meta description <textarea>fields,<script>and<style>blocks, and HTML tag attributes- front-end edit forms (
layout=edit), so editing an article never saves map HTML over your shortcode
A shortcode without address and without a lat/lng pair is replaced by an HTML comment (slgm: invalid {smartmap}), visible only in the page source.
Note on "Consent Box Position": a shortcode map's "no decision" state is always the inline placeholder shown where the map sits — the Appearance → Consent Box Position setting does not change this. That setting only governs how auto-detected maps are blocked. See Where each position applies.