Google Maps
A Strapi plugin allowing you to implement a Google Maps custom field into your content-types, which can be used to pick and retrieve locations.
🚀🗺️ Strapi Google Maps
A Strapi plugin allowing you to implement a Google Maps custom field into your content-types, which can be used to pick and retrieve locations.
✨ Usage
The API response of a Strapi content-type implementing this google-maps custom field could look as follows:
1{
2 "data": [
3 {
4 "id": 1,
5 "documentId": "tub3d05itueb9vw1bux9f66a",
6 "location": {
7 "address": "Königswall 21, 44137 Dortmund, Germany",
8 "coordinates": {
9 "lat": 51.5164315,
10 "lng": 7.455616999999997
11 },
12 "geohash": "u1jm1dm0bqyu"
13 },
14 "createdAt": "2025-05-06T11:45:32.505Z",
15 "updatedAt": "2025-05-06T11:53:48.099Z",
16 "publishedAt": "2025-05-06T11:53:48.102Z"
17 }
18 ],
19 "meta": {
20 "pagination": {
21 "page": 1,
22 "pageSize": 25,
23 "pageCount": 1,
24 "total": 1
25 }
26 }
27}When available, the saved location also includes parsed address components and basic place metadata. The address is sourced directly from the Google Places API (formatted address) when you pick from autocomplete, or from the Google Geocoding API when you click on the map.
Example with extended attributes:
1{
2 "data": [
3 {
4 "id": 1,
5 "documentId": "tub3d05itueb9vw1bux9f66a",
6 "location": {
7 "address": "Königswall 21, 44137 Dortmund, Germany",
8 "coordinates": { "lat": 51.5164315, "lng": 7.455617 },
9 "geohash": "u1jm1dm0bqyu",
10 "components": {
11 "streetNumber": "21",
12 "route": "Königswall",
13 "postalCode": "44137",
14 "city": "Dortmund",
15 "state": "NW",
16 "country": "Germany"
17 },
18 "place": {
19 "id": "ChIJ2aVjP5V2uEcRxu2iWZhbU3w",
20 "name": "Some Business Name",
21 "types": ["point_of_interest", "establishment"]
22 }
23 },
24 "createdAt": "2025-05-06T11:45:32.505Z",
25 "updatedAt": "2025-05-06T11:53:48.099Z",
26 "publishedAt": "2025-05-06T11:53:48.102Z"
27 }
28 ],
29 "meta": { "pagination": { "page": 1, "pageSize": 25, "pageCount": 1, "total": 1 } }
30}Fields:
- location.address: Places formatted address (autocomplete) or Geocoding formatted address (map click).
- location.components:
- streetNumber
- route (full street name using
long_name) - postalCode
- city
- state (short form when provided, e.g., "NRW")
- country (full name)
- location.place:
- id: Places
place_id/id - name: Business display name (if applicable)
- types: Array of place types
- id: Places
You can configure this plugin inside your Strapi dashboard's settings tab (e.g. to enter your API key).
❗ Requirements
- Strapi v5
- To use the plugin without restrictions, you should consider getting an API key for the Google Maps Platform, with additional access to the Places API.
⚠️ Migrating to v3
After upgrading to v3, when testing the Google Maps field in the Strapi admin, carefully watch the browser console for Google Maps Platform errors. These messages commonly indicate missing API key permissions or restrictive key settings (e.g., missing Places or Geocoding API, wrong HTTP referrer restrictions). The errors include links/instructions to resolve the issue in Google Cloud Console. Follow them to:
- Enable required APIs (Maps JavaScript API, Places API, Geocoding API)
- Adjust key restrictions (HTTP referrers, IP/app restrictions)
- Regenerate/update keys if necessary
Once permissions are corrected, reload the admin and retest the field.
🔧 Installation
You just need to install the strapi-google-maps package via npm, at the root of your strapi project.
npm i @amicaldo/strapi-google-maps
# IMPORTANT: For Strapi versions before 5 install an older version instead:
npm i @amicaldo/strapi-google-maps@1.1.5
# IMPORTANT: For Strapi versions before 4.11.0 install an older version instead:
npm i @amicaldo/strapi-google-maps@1.0.4To make Google Maps work, you should take a look at the next section.
After restarting your Strapi app, Google Maps should be listed as one of your plugins.
🚀 Strapi Configuration (required)
Allow all Google Maps assets to be loaded correctly by customizing the strapi::security middleware inside ./config/middlewares.js.
Instead of:
1export default [
2 // ...
3 'strapi::security',
4 // ...
5];Write:
1export default [
2 // ...
3 {
4 name: 'strapi::security',
5 config: {
6 contentSecurityPolicy: {
7 useDefaults: true,
8 directives: {
9 'connect-src': ["'self'", 'https:'],
10 'script-src': ["'self'", 'unsafe-inline', 'https://maps.googleapis.com'],
11 'media-src': [
12 "'self'",
13 'blob:',
14 'data:',
15 'https://maps.gstatic.com',
16 'https://maps.googleapis.com',
17 ],
18 'img-src': [
19 "'self'",
20 'blob:',
21 'data:',
22 'https://maps.gstatic.com',
23 'https://maps.googleapis.com',
24 'khmdb0.google.com',
25 'khmdb0.googleapis.com',
26 'khmdb1.google.com',
27 'khmdb1.googleapis.com',
28 'khm.google.com',
29 'khm.googleapis.com',
30 'khm0.google.com',
31 'khm0.googleapis.com',
32 'khm1.google.com',
33 'khm1.googleapis.com',
34 'khms0.google.com',
35 'khms0.googleapis.com',
36 'khms1.google.com',
37 'khms1.googleapis.com',
38 'khms2.google.com',
39 'khms2.googleapis.com',
40 'khms3.google.com',
41 'khms3.googleapis.com',
42 'streetviewpixels-pa.googleapis.com',
43 'market-assets.strapi.io',
44 ],
45 },
46 },
47 },
48 },
49 // ...
50];Features
- Default latitude and longitude;
- Google Maps API key can be set in the environment variables (
GOOGLE_MAPS_API_KEY);
👨💻 Manual Installation (not recommended)
Navigate into your Strapi's plugins folder and clone this repository. Then navigate into this plugin's directory.
cd ./src/plugins
git clone https://github.com/amicaldo/strapi-google-maps.git
cd ./strapi-google-mapsInstall the dependencies using npm and compile the server side part.
npm install
npm run buildFrom your project's root directory, enable the plugin inside ./config/plugins.js.
1module.exports = {
2 // ...
3 'google-maps': {
4 enabled: true,
5 resolve: './src/plugins/strapi-google-maps',
6 },
7 // ...
8};To make Google Maps work, you should take a look at the previous section.
Lastly, recompile the admin panel of your Strapi project.
npm run buildAcknowledgements
- @roodekk
- @maektwain
- @prinzjuliano
- @roes
- @candidosales
Install now
npm install @amicaldo/strapi-google-maps
Create your own plugin
Check out the available plugin resources that will help you to develop your plugin or provider and get it listed on the marketplace.