Skip to content

Troubleshooting ​

“Google Maps rejected the API key” ​

The field shows this notice, and switches to OpenStreetMap, when Google refuses the Browser key of the Google Maps service in Settings → Plugins → Geo Maps. Your front-end maps switch too, so nothing breaks while you fix it. In the Google Cloud console:

  1. Enable the Maps JavaScript API, Places API and Geocoding API for the key’s project, and the Maps Static API if you use img(). Without the Geocoding API, Geo Maps uses OpenStreetMap to find the address when the pin is dragged.
  2. Under the key’s Application restrictions → Website restrictions, add every domain the control panel and site run on, including local ones such as *.ddev.site/* or localhost:*.
  3. Make sure billing is enabled on the project. Google refuses keys on projects without it.

Changes can take a few minutes to apply. Reload the page afterwards.

Location search returns nothing ​

Work through these in order:

  • Is the place found? Searches by address are geocoded first. If the address can’t be found, there are no results. Try a simpler address or pass country: 'AU' (your country code) to narrow it down.
  • Is the radius big enough? The default is 50 in the chosen unit (km unless you say mi).
  • Are the entries indexed? Coordinates are indexed when entries are saved. After importing content straight into the database, restoring a backup, or changing a field’s type, rebuild the index:
bash
php craft geomaps/lookup/rebuild
  • Do the entries have coordinates? An entry with only an address (for example from a feed without coordinates) can’t be found by distance. Open it and pick the address from the search, or import coordinates. With Geo Maps Pro, missing coordinates are looked up automatically, or with php craft geomaps/geocode.

Check which entries have no location:

twig
{{ craft.entries().section('stores').storeLocation(':empty:').count() }}

“Which zone” (contains) returns nothing ​

  • Only areas count: polygons and multipolygons. Markers and lines are ignored.
  • The address must fall inside the area. Holes cut out of a zone don’t count as part of it.
  • Zones saved before upgrading to a version with contains are indexed by the update migration. If you imported zones directly into the database, run php craft geomaps/lookup/rebuild.

Maps don’t appear on the front end ​

  • Your layout must output Craft’s head and body hooks. embed() adds its scripts and styles through them. Make sure your layout has head() before </head>, beginBody() after <body> and endBody() before </body>, each output with double curly braces.
  • Check for a Content Security Policy. If your site sends one, allow the map services (see below).
  • Give the map a size. embed() sets width and height; if your CSS overrides them, make sure the map container still has a height.

The map tiles are grey or say “Access blocked” ​

The free tile.openstreetmap.org tiles are for light use. Busy public sites can be blocked under the OpenStreetMap tile usage policy. Choose the Mapbox service, or under OpenStreetMap → Use another tile provider set Map tiles URL to a provider such as Stadia Maps, MapTiler or Thunderforest — see Configuration.

With Mapbox, grey tiles usually mean the access token is mistyped or its URL restrictions don’t include the domain, or the style URL is wrong. The preview under Style on the settings page shows whether the tiles load.

img() returns nothing ​

Static map images come from Google (the Maps Static API, enabled on the Browser key) with the Google Maps service, or Mapbox with the Mapbox service. Allow your site’s domain in the key’s or token’s restrictions. With OpenStreetMap, which has no static images, img() and imgSrcSet() return null, so always check before outputting:

twig
{% set src = entry.storeLocation.img({ width: 600, height: 300 }) %}
{% if src %}<img src="{{ src }}" alt="Map">{% endif %}

Address search in the field finds the wrong places ​

  • Set Limit Search to Countries in the field’s settings to the countries your entries are in (up to 5).
  • Results are biased towards the area shown on the map, so pan the map nearer first.
  • With the OpenStreetMap service, search uses Photon. Mapbox and Google Places often find addresses more reliably, and Google Places knows more businesses; choose another map service if you need them.

Mapbox searches use OpenStreetMap ​

If Mapbox refuses a lookup, Geo Maps uses OpenStreetMap for 10 minutes and logs a warning in storage/logs/web.log. Check the access token and its URL restrictions, and that your Mapbox account has a card for permanent geocoding (or set mapboxPermanent to false; see Mapbox Maps).

Content Security Policy ​

If your site sends a Content-Security-Policy header, allow the services Geo Maps uses:

DirectiveAllowNeeded for
img-srchttps://tile.openstreetmap.org (or your tile provider)OpenStreetMap tiles
img-src, connect-srchttps://api.mapbox.comMapbox tiles and static images; address suggestions and reverse lookups (only with Mapbox)
connect-srchttps://photon.komoot.io https://nominatim.openstreetmap.orgAddress search and reverse lookup in the control panel
script-src, img-src, connect-srchttps://maps.googleapis.com https://maps.gstatic.comGoogle maps, Places search and static images (only with a Google key)
script-srcA nonce or 'unsafe-inline'embed() adds a small inline script with each map’s settings

Server-side geocoding for location search runs from your server, so it needs no browser rule, but your server must be able to reach nominatim.openstreetmap.org (or maps.googleapis.com with Google, or api.mapbox.com with Mapbox).

Still stuck? ​

Email support@suprim.com.au with your Craft and Geo Maps versions, what you expected, and what happened. Lines from storage/logs/web.log mentioning geomaps help a lot.