Maps with addresses, directions and a wait for consent

Put several places on one map by typing their addresses, add a Get directions link, and keep Google maps waiting until visitors agree to cookies.

By Darryl Waterhouse · · 4 min read

A map on your Contact page answers the question every visitor has: where are you? Domma CMS maps have grown up over the last few releases. You can now mark several places on one map by typing their addresses, add a Get directions link, and keep Google's map from loading until a visitor has said yes to its cookies.

One map, several places

If you have more than one shop, office or venue, the [map] tag takes a list of pins, split by |. Each pin can be an address or postcode, with a label in front:

[map pins="ACME North = Leeds Town Hall, Leeds | ACME York = York railway station, York | ACME Workshop = Manchester Piccadilly railway station, Manchester" directions="true" caption="ACME offices in the north" /]

The map zooms to fit every pin. Click one and its label appears, with a directions link to that place.

A map of northern England with three pins, one open showing ACME York and a Get directions link

A map with several pins is drawn with OpenStreetMap on a page your own site serves, so it is not held back by the cookie banner (more on that below). It takes up to 50 pins, and you can still give coordinates (53.958,-1.093 York) where you know them.

Switch on address look-ups first

Turning an address into a point on the map needs a look-up service. Domma uses OpenStreetMap's Nominatim, and because that means sending something to a third party, it is off until you switch it on.

Go to Site Settings > General > Maps and tick Address look-ups, then save.

The Maps section of Site Settings with the Address look-ups switch turned on

What it sends, and when:

  • When you save a page, not when someone visits. The site looks up any addresses in your [map pins] tags in the background, one a second, and remembers the answers. Visitors never wait for a look-up and their browsers never talk to Nominatim.
  • Only the address text and your site's address. Nothing about your visitors.
  • Switching it on catches up. Addresses already in your pages are looked up straight away, so you do not need to save each page again.

Until an address is found, its pin is simply left off. One that cannot be found is tried again when you save the page a day or more later. If a pin is missing, try a fuller address or a postcode.

Pins inside blocks or collection entries are not looked up, so use coordinates there. With look-ups off, coordinates still work everywhere.

Add directions="true" and a Get directions link appears under the map. It opens Google's route planner to your place in a new tab, so visitors on a phone go straight to turn-by-turn directions. Prefer your own words? Use directions="Find us".

This works on a single-place map too:

[map address="York railway station, York" zoom="15" directions="true" caption="ACME York showroom" /]

A Google map of York city centre with the caption ACME York showroom and a Get directions link

If you would rather click than type, the Map form in the page editor has a Directions link tick box and a Several pins box.

A single-place map comes from Google, and Google may set its own cookies when it loads. So while your cookie banner is on, a Google map no longer loads with the page. Visitors see a short notice, "This map is provided by Google, which may set its own cookies", and a Load map button.

A map space holding a notice that Google may set cookies and a Load map button, with the cookie banner at the bottom of the page

  • Accept the banner's Functional cookies and maps show on every page from then on.
  • Load map shows the maps on that page only, without recording consent. It works even after a visitor has said no.
  • Withdraw consent and the maps are held back again.

The same goes for a Google Maps embed you added yourself. The Get directions link stays visible either way. With the cookie banner off, maps load just as they always did.

Want the banner to say plainly what Functional cookies are for on your site? You can now name and describe each category in your own words.

Try it

  1. Open Site Settings > General > Maps, tick Address look-ups and save.
  2. Edit your Contact or Find us page and add a [map pins="..."] with your addresses and directions="true".
  3. Save, wait a few seconds, then view the page and click a pin.

If your cookie banner is on, check the page in a private window too, so you see what a new visitor sees.