@gmap-vue/v3

中文文档
2.2.2发布于 2026/07/15MITTypeScriptESM + CJS构建来源已验证近 30 天下载 1.3万

Google Maps components and composables for Vue 3

原始使用文档
文档目录7 节
  1. Documentation
  2. Installation
  3. Quick start
  4. Google Maps API key
  5. Public entrypoints
  6. Migrating from Vue 2
  7. Contributing

@gmap-vue/v3

CI Documentation jsDelivr

Vue 3 components and composables for the Google Maps JavaScript API.

@gmap-vue/v3 is the actively developed GmapVue package. It provides Vue wrappers for maps, markers, info windows, shapes, clusters, layers, autocomplete, and Street View, plus composables for accessing the underlying Google Maps instances.

Documentation

Installation

npm install @gmap-vue/v3
pnpm add @gmap-vue/v3
yarn add @gmap-vue/v3

Quick start

Register the plugin once in your Vue app:

import { createApp } from 'vue';
import { createGmapVuePlugin } from '@gmap-vue/v3';
import '@gmap-vue/v3/dist/style.css';
import App from './App.vue';

createApp(App)
  .use(
    createGmapVuePlugin({
      load: {
        key: import.meta.env.VITE_GOOGLE_MAPS_API_KEY,
      },
    }),
  )
  .mount('#app');

Then use the public components in your templates:

<template>
  <GmvMap
    :center="{ lat: -34.6037, lng: -58.3816 }"
    :zoom="12"
    style="width: 100%; height: 500px"
  >
    <GmvMarker :position="{ lat: -34.6037, lng: -58.3816 }" />
  </GmvMap>
</template>

Google Maps API key

You need a browser API key for the Google Maps JavaScript API. For production applications:

  • restrict the key by HTTP referrer,
  • enable only the APIs and libraries your app uses,
  • monitor billing and quota in Google Cloud Console,
  • avoid calling paid APIs from high-frequency map events.

Public entrypoints

Use the package entrypoints instead of deep imports:

import { createGmapVuePlugin, GmvMap } from '@gmap-vue/v3';
import { useMapPromise } from '@gmap-vue/v3/composables';
import { mapPromiseKey } from '@gmap-vue/v3/keys';
import type { IMapLayerVueComponentExpose } from '@gmap-vue/v3/interfaces';

Migrating from Vue 2

The Vue 3 package changes the plugin structure, component names, and instance-access patterns. See the Vue 3 migration guide before migrating from the legacy gmap-vue package.

Contributing

Contributions are welcome. Please read the repository-level README.md, AGENTS.md, and Copilot instructions before opening a PR.

版本与发布记录

@gmap-vue/v3 共发布 16 个版本,首次发布于 2023/06/05;过去 12 个月发布了 3 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.2.2latest2026/07/154 个月前
2.2.12026/06/155 个月前
2.2.02026/03/168 个月前
2.1.52025/01/031.9 年前
2.1.42025/01/031.9 年前
2.1.32024/11/162 年前

关于 @gmap-vue/v3 的常见问题

@gmap-vue/v3 是什么?

Google Maps components and composables for Vue 3

如何安装 @gmap-vue/v3?

在项目目录运行 npm install @gmap-vue/v3,或使用 pnpm add / yarn add / bun add。

@gmap-vue/v3 支持 TypeScript 吗?

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

@gmap-vue/v3 支持 ESM 还是 CommonJS?

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

@gmap-vue/v3 需要什么版本的 Node.js?

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

@gmap-vue/v3 可以商用吗?

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

@gmap-vue/v3 的下载量有多少?

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

@gmap-vue/v3 还在维护吗?

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