| title | Configuration |
|---|
There are two ways to configure Maps, via the Craft CP or using a config file (for advanced configuration).
Below is a list of the various services supported by Maps and links on how to get their tokens.
No token required
No token required
No token required
You will need to enable the Maps JavaScript API and Places API for if using Google for the map tiles, and the Places API and Geocoding API if you are using it for the Geo service.
You can use the same key for both map tiles and geo service, no configuration needed!
We currently only support Apple MapKit for map tiles only.
You can use the same key for both map tiles and geo service, no configuration needed!
ipstack offer free and paid-for versions of their API.
MaxMind offer free lookup database that must be stored locally, and a more accurate paid-for version of their API.
You can get to the Maps settings in the Craft CP by navigating to "Settings" ->
"Maps" in an environment where allowAdminChanges is set to true.
For advanced configuration create a simplemap.php file in your config folder.
This file should return an array of Maps settings.
<?php
return [
'mapToken' => '123abc',
];Default: MapTiles::Wikimedia
The map tileset to use. Must be set to one of the MapTiles constants.
<?php
use ether\simplemap\enums\MapTiles;
return [
'mapTiles' => MapTiles::CartoVoyager,
];Default: ''
The token to use with your selected map tileset. This is only required when you are using a tileset that requires a token.
Mapbox & Google Maps For these services your token should be a string containing the token.
<?php
return [
'mapToken' => '',
];Apple MapKit
Your token should be an array containing privateKey, teamId, keyId.
<?php
return [
'mapToken' => [
'privateKey' => '',
'teamId' => '',
'keyId' => '',
],
];Here
The token should be an array containing appId, apiKey, appCode.
<?php
return [
'mapToken' => [
'appId' => '',
'apiKey' => '',
'appCode' => '',
],
];Default: GeoService::Nominatim
The geocoding service to use. Must be set to one of the GeoService constants.
<?php
use ether\simplemap\enums\GeoService;
return [
'geoService' => GeoService::GoogleMaps,
];Default: ''
The token to use with your selected geocoding service. This is only required when you are using a geocoding that requires a token.
Mapbox & Google Maps For these services your token should be a string containing the token.
<?php
return [
'geoToken' => '',
];Here
The token should be an array containing appId, appCode.
<?php
return [
'geoToken' => [
'appId' => '',
'appCode' => '',
],
];Default: false
Will disable the automatic population of missing field data. This can be useful in preventing API spam when importing lots of map data.
Default: 'https://nominatim.openstreetmap.org'
The base URL for the Nominatim service. Override to use a self-hosted instance or a proxy.
Default: GeoLocationService::None
The geolocation service to use. Must be set to one of the GeoLocationService
constants.
<?php
use ether\simplemap\services\GeoLocationService;
return [
'geoLocationService' => GeoLocationService::MaxMind,
];Default: ''
The token to use with your selected geolocation service. This is only required when you are using a geolocation that requires a token.
ipstack For this services your token should be a string containing the token.
<?php
return [
'geoLocationToken' => '',
];MaxMind
The token should be an array containing accountId, licenseKey.
<?php
return [
'geoLocationToken' => [
'accountId' => '',
'licenseKey' => '',
],
];Default: 'P2M'
A string (a duration interval) or int (in seconds) of how long we should cache IP lookups.
Default: false
Will automatically redirect the user according to geoLocationRedirectMap when
set to true.
Default: []
This dictates what site the user is redirected to based off their IPs location.
It should be a key value array where key is the handle of the site to redirect, and value is a key value array of user location properties and their required matches or an string to catch all.
For more details on how to setup your geolocation redirects have a look at the Geolocation / Redirect docs.
<?php
return [
'geoLocationRedirectMap' => [
'uk' => [ 'country' => 'uk' ],
'eu' => [ 'isEU' => true ],
'global' => '*',
],
];