@amicaldo/strapi-google-maps

中文文档
3.0.2发布于 2026/01/13MITTypeScriptESM + CJS近 30 天下载 3500

A Google Maps custom field for Strapi, allowing you to pick a location.

原始使用文档
文档目录8 节
  1. ✨ Usage
  2. ❗ Requirements
  3. ⚠️ Migrating to v3
  4. 🔧 Installation
  5. 🚀 Strapi Configuration (required)
  6. Features
  7. 👨‍💻 Manual Installation (not recommended)
  8. Acknowledgements

🚀🗺️ Strapi Google Maps

Preview

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:

{
  "data": [
    {
      "id": 1,
      "documentId": "tub3d05itueb9vw1bux9f66a",
      "location": {
        "address": "Königswall 21, 44137 Dortmund, Germany",
        "coordinates": {
          "lat": 51.5164315,
          "lng": 7.455616999999997
        },
        "geohash": "u1jm1dm0bqyu"
      },
      "createdAt": "2025-05-06T11:45:32.505Z",
      "updatedAt": "2025-05-06T11:53:48.099Z",
      "publishedAt": "2025-05-06T11:53:48.102Z"
    }
  ],
  "meta": {
    "pagination": {
      "page": 1,
      "pageSize": 25,
      "pageCount": 1,
      "total": 1
    }
  }
}

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:

{
  "data": [
    {
      "id": 1,
      "documentId": "tub3d05itueb9vw1bux9f66a",
      "location": {
        "address": "Königswall 21, 44137 Dortmund, Germany",
        "coordinates": { "lat": 51.5164315, "lng": 7.455617 },
        "geohash": "u1jm1dm0bqyu",
        "components": {
          "streetNumber": "21",
          "route": "Königswall",
          "postalCode": "44137",
          "city": "Dortmund",
          "state": "NW",
          "country": "Germany"
        },
        "place": {
          "id": "ChIJ2aVjP5V2uEcRxu2iWZhbU3w",
          "name": "Some Business Name",
          "types": ["point_of_interest", "establishment"]
        }
      },
      "createdAt": "2025-05-06T11:45:32.505Z",
      "updatedAt": "2025-05-06T11:53:48.099Z",
      "publishedAt": "2025-05-06T11:53:48.102Z"
    }
  ],
  "meta": { "pagination": { "page": 1, "pageSize": 25, "pageCount": 1, "total": 1 } }
}

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

You can configure this plugin inside your Strapi dashboard's settings tab (e.g. to enter your API key).

Configuration

❗ 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/[email protected]

# IMPORTANT: For Strapi versions before 4.11.0 install an older version instead:
npm i @amicaldo/[email protected]

To 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:

export default [
  // ...
  'strapi::security',
  // ...
];

Write:

export default [
  // ...
  {
    name: 'strapi::security',
    config: {
      contentSecurityPolicy: {
        useDefaults: true,
        directives: {
          'connect-src': ["'self'", 'https:'],
          'script-src': ["'self'", 'unsafe-inline', 'https://maps.googleapis.com'],
          'media-src': [
            "'self'",
            'blob:',
            'data:',
            'https://maps.gstatic.com',
            'https://maps.googleapis.com',
          ],
          'img-src': [
            "'self'",
            'blob:',
            'data:',
            'https://maps.gstatic.com',
            'https://maps.googleapis.com',
            'khmdb0.google.com',
            'khmdb0.googleapis.com',
            'khmdb1.google.com',
            'khmdb1.googleapis.com',
            'khm.google.com',
            'khm.googleapis.com',
            'khm0.google.com',
            'khm0.googleapis.com',
            'khm1.google.com',
            'khm1.googleapis.com',
            'khms0.google.com',
            'khms0.googleapis.com',
            'khms1.google.com',
            'khms1.googleapis.com',
            'khms2.google.com',
            'khms2.googleapis.com',
            'khms3.google.com',
            'khms3.googleapis.com',
            'streetviewpixels-pa.googleapis.com',
            'market-assets.strapi.io',
          ],
        },
      },
    },
  },
  // ...
];

Features

  • Default latitude and longitude;
  • Google Maps API key can be set in the environment variables (GOOGLE_MAPS_API_KEY);

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-maps

Install the dependencies using npm and compile the server side part.

npm install
npm run build

From your project's root directory, enable the plugin inside ./config/plugins.js.

module.exports = {
  // ...
  'google-maps': {
    enabled: true,
    resolve: './src/plugins/strapi-google-maps',
  },
  // ...
};

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 build

Acknowledgements

  • @roodekk
  • @maektwain
  • @prinzjuliano
  • @roes
  • @candidosales

版本与发布记录

@amicaldo/strapi-google-maps 共发布 18 个版本,首次发布于 2023/05/24;过去 12 个月发布了 1 个版本。

版本发布日期距今
3.0.2latest2026/01/139 个月前
3.0.12025/10/281 年前
3.0.02025/10/281 年前
2.0.32025/09/221.1 年前
2.0.22025/05/131.5 年前
2.0.12025/05/061.5 年前

关于 @amicaldo/strapi-google-maps 的常见问题

@amicaldo/strapi-google-maps 是什么?

A Google Maps custom field for Strapi, allowing you to pick a location.

如何安装 @amicaldo/strapi-google-maps?

在项目目录运行 npm install @amicaldo/strapi-google-maps,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@strapi/sdk-plugin(^5.3.2)、@strapi/strapi(^5.12.5)、react(^18.3.1)、react-dom(^18.3.1)、react-router-dom(^6.30.3)、styled-components(^6.1.17)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@amicaldo/strapi-google-maps 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@amicaldo/strapi-google-maps 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@amicaldo/strapi-google-maps 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18.0.0 <=22.x.x。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@amicaldo/strapi-google-maps 可以商用吗?

@amicaldo/strapi-google-maps 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@amicaldo/strapi-google-maps 的下载量有多少?

根据 npm 官方下载统计,@amicaldo/strapi-google-maps 在 2026/10/06 – 2026/11/04 这 30 天内被下载 3,500 次,日均约 117 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@amicaldo/strapi-google-maps 还在维护吗?

最新版本 3.0.2 发布于 2026/01/13(9 个月前);至今共发布 18 个版本,其中过去 12 个月发布了 1 个;首次发布于 2023/05/24。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。