@flowingcode/google-map

中文文档
3.10.1发布于 2026/10/15Apache-2.0CommonJS近 30 天下载 2050

Google Maps web components

原始使用文档
文档目录10 节
  1. Features
  2. Download release
  3. npm install
  4. Usage
  5. Building and running demo
  6. Release notes
  7. Issue tracking
  8. Contributions
  9. Getting started
  10. Advanced markers

Published on npm

Google Map

Web components for embedding and interacting with Google Maps.

Features

  • Display an interactive Google Map (google-map)
  • Add draggable and customizable markers (google-map-marker)
  • Add markers based on Google's Advanced Markers (google-map-advanced-marker)
  • Draw polygons, polylines, and rectangles on the map (google-map-poly)
  • Define geographic points for use with poly elements (google-map-point)
  • Support for marker clustering
  • Touch-and-hold gesture to simulate right-click on mobile

Download release

Available on npm

npm install

npm install @flowingcode/google-map

Then import the components you need like:

import '@flowingcode/google-map/google-map.js';
import '@flowingcode/google-map/google-map-marker.js';
import '@flowingcode/google-map/google-map-advanced-marker.js';

Usage

<google-map api-key="YOUR_API_KEY" fit-to-markers>
  <google-map-marker latitude="37.78" longitude="-122.4" draggable="true"></google-map-marker>
</google-map>

Building and running demo

  • git clone repository
  • npm install
  • npm start

The demo will open automatically at http://localhost:8000/demo/. A valid Google Maps API key is required — pass it as a query parameter:

http://localhost:8000/demo/?api-key=YOUR_API_KEY

For polys:

http://localhost:8000/demo/polys.html?api-key=YOUR_API_KEY

For advanced markers:

http://localhost:8000/demo/advanced-markers.html?api-key=YOUR_API_KEY
http://localhost:8000/demo/advanced-markers-clustering.html?api-key=YOUR_API_KEY

For markers clustering (optional map-id and custom-renderer=1 query parameters):

http://localhost:8000/demo/markers-clustering.html?api-key=YOUR_API_KEY

Release notes

See here

Issue tracking

The issues for this add-on are tracked on its github.com page. All bug reports and feature requests are appreciated.

Contributions

Contributions are welcome. There are two primary ways you can contribute: by reporting issues or by submitting code changes through pull requests. To ensure a smooth and effective process for everyone, please follow the guidelines below for the type of contribution you are making.

1. Reporting Bugs and Requesting Features

Creating an issue is a highly valuable contribution. If you've found a bug or have an idea for a new feature, this is the place to start.

  • Before creating an issue, please check the existing issues to see if your topic is already being discussed.
  • If not, create a new issue. Try to keep the scope minimal but as detailed as possible.

A Note on Bug Reports

While all details are important, a minimal, reproducible example is the most critical part of your report. It's essential because it removes ambiguity and allows our team to observe the problem firsthand, exactly as you are experiencing it.

2. Contributing Code via Pull Requests

As a first step, please refer to our Development Conventions page to find information about Conventional Commits & Code Style requirements.

Then, follow these steps for creating a contribution:

  • Fork this project.
  • Create an issue to this project about the contribution (bug or feature) if there is no such issue about it already. Try to keep the scope minimal.
  • Develop and test the fix or functionality carefully. Only include minimum amount of code needed to fix the issue.
  • For commit message, use Conventional Commits to describe your change.
  • Send a pull request for the original project.
  • Comment on the original issue that you have implemented a fix for it.

Developer Guide

Getting started

<google-map api-key="YOUR_API_KEY" latitude="37.78" longitude="-122.4" zoom="12">
  <google-map-marker latitude="37.78" longitude="-122.4" title="My location"></google-map-marker>
</google-map>

You need a valid Google Maps API key to use these components.

Advanced markers

google.maps.Marker, used by google-map-marker, is deprecated in favor of AdvancedMarkerElement. Use google-map-advanced-marker to use Advanced Markers instead. Both elements can be used on the same map.

Advanced Markers require a Map ID (DEMO_MAP_ID can be used for testing). Note that when a Map ID is set, the styles property of google-map is not applied: the map is styled from the Google Cloud console instead.

<google-map api-key="YOUR_API_KEY" map-id="YOUR_MAP_ID" fit-to-markers>
  <google-map-advanced-marker slot="markers" latitude="37.78" longitude="-122.4" title="My location"
      pin-background="#FBBC04" draggable="true"></google-map-advanced-marker>
</google-map>

版本与发布记录

@flowingcode/google-map 共发布 25 个版本,首次发布于 2020/05/20;过去 12 个月发布了 2 个版本。

版本发布日期距今
3.10.1latest2026/10/151 个月前
3.10.02026/10/101 个月前
3.9.02025/09/241.1 年前
3.8.22025/05/311.5 年前
3.8.12024/12/061.9 年前
3.8.02024/09/262 年前

关于 @flowingcode/google-map 的常见问题

@flowingcode/google-map 是什么?

Google Maps web components

如何安装 @flowingcode/google-map?

在项目目录运行 npm install @flowingcode/google-map,或使用 pnpm add / yarn add / bun add。

@flowingcode/google-map 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/flowingcode__google-map 是否存在。

@flowingcode/google-map 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@flowingcode/google-map 可以商用吗?

@flowingcode/google-map 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@flowingcode/google-map 的下载量有多少?

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

@flowingcode/google-map 还在维护吗?

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