@capgo/nativegeocoder

中文文档
8.0.31发布于 2026/05/11MPL-2.0TypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 1.4万

Capacitor plugin for native forward and reverse geocoding

此软件包已被标记为弃用

This package has moved to @capgo/capacitor-nativegeocoder. Please install @capgo/capacitor-nativegeocoder instead.

原始使用文档
文档目录14 节
  1. ➡️ Get Instant updates for your App with Capgo
  2. Missing a feature? We’ll build the plugin for you 💪
  3. Documentation
  4. Compatibility
  5. Install
  6. iOS
  7. Android
  8. Web
  9. API
  10. reverseGeocode(...)
  11. forwardGeocode(...)
  12. getPluginVersion()
  13. Interfaces
  14. Thanks

@capgo/nativegeocoder

Capgo - Instant updates for Capacitor

Capacitor plugin for native forward and reverse geocoding

Documentation

The most complete doc is available here: https://capgo.app/docs/plugins/nativegeocoder/

Compatibility

Plugin versionCapacitor compatibilityMaintained
v8.*.*v8.*.*✅
v7.*.*v7.*.*On demand
v6.*.*v6.*.*❌
v5.*.*v5.*.*❌

Note: The major version of this plugin follows the major version of Capacitor. Use the version that matches your Capacitor installation (e.g., plugin v8 for Capacitor 8). Only the latest major version is actively maintained.

Install

npm install @capgo/nativegeocoder
npx cap sync

then import this into your code:

import { NativeGeocoder } from '@capgo/nativegeocoder';

iOS

Apple requires privacy descriptions to be specified in Info.plist for location information:

  • NSLocationAlwaysAndWhenInUseUsageDescription (Privacy - Location Always Usage Description)
  • NSLocationWhenInUseUsageDescription (Privacy - Location When In Use Usage Description)

Read about Configuring Info.plist in the iOS Guide for more information on setting iOS permissions in Xcode The IOS implementation require internet

Android

This API requires the following permissions be added to your AndroidManifest.xml:

<!-- Geolocation API -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature android:name="android.hardware.location.gps" />

Web

This API requires a Google API key to be set in the apiKey field of the ForwardOptions or ReverseOptions interfaces.

There is no way to use this plugin on the web without a Google API key.

The return data is limited to the data available from the native API on the device, as example formatted_address is not available in web implementation, as it's not available in the native API.

API

reverseGeocode(...)

reverseGeocode(options: ReverseOptions) => Promise<{ addresses: Address[]; }>

Convert latitude and longitude to an address

ParamType
optionsReverseOptions

Returns: Promise<{ addresses: Address[]; }>

Since: 0.0.1


forwardGeocode(...)

forwardGeocode(options: ForwardOptions) => Promise<{ addresses: Address[]; }>

Convert an address to latitude and longitude

ParamType
optionsForwardOptions

Returns: Promise<{ addresses: Address[]; }>

Since: 0.0.1


getPluginVersion()

getPluginVersion() => Promise<{ version: string; }>

Get the native Capacitor plugin version

Returns: Promise<{ version: string; }>


Interfaces

Address

PropType
latitudenumber
longitudenumber
countryCodestring
countryNamestring
postalCodestring
administrativeAreastring
subAdministrativeAreastring
localitystring
subLocalitystring
thoroughfarestring
subThoroughfarestring
areasOfIntereststring[]

ReverseOptions

PropTypeDescription
latitudenumberlatitude is a number representing the latitude of the location.
longitudenumberlongitude is a number representing the longitude of the location.
useLocalebooleanLocalise the results to the given locale.
defaultLocalestringlocale is a string in the format of language_country, for example en_US.
maxResultsnumberMax number of results to return.
apiKeystringOnly used for web platform to use google api
resultTypestringOnly used for web platform to use google api

ForwardOptions

PropTypeDescription
addressStringstringaddress is a string of the address to be geocoded.
useLocalebooleanLocalise the results to the given locale.
defaultLocalestringlocale is a string in the format of language_country, for example en_US.
maxResultsnumberMax number of results to return.
apiKeystringOnly used for web platform to use google api

Thanks

To @sebastianbaar and his work on cordova-plugin-nativegeocoder what he made was very inspiring

版本与发布记录

@capgo/nativegeocoder 共发布 232 个版本,首次发布于 2022/06/29;过去 12 个月发布了 37 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
8.0.31latest2026/05/115 个月前
8.0.302026/05/115 个月前
8.0.292026/04/276 个月前
8.0.282026/04/206 个月前
8.0.272026/04/136 个月前
8.0.242026/03/167 个月前

关于 @capgo/nativegeocoder 的常见问题

@capgo/nativegeocoder 是什么?

Capacitor plugin for native forward and reverse geocoding注意:该包已被作者标记为弃用——This package has moved to @capgo/capacitor-nativegeocoder. Please install @capgo/capacitor-nativegeocoder instead.

如何安装 @capgo/nativegeocoder?

在项目目录运行 npm install @capgo/nativegeocoder,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@capacitor/core(>=8.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@capgo/nativegeocoder 支持 TypeScript 吗?

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

@capgo/nativegeocoder 支持 ESM 还是 CommonJS?

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

@capgo/nativegeocoder 可以商用吗?

@capgo/nativegeocoder 使用 MPL-2.0 许可。弱 Copyleft:可以商用,也可以和闭源代码一起使用;但如果分发时修改了 MPL 授权的文件,这些文件的修改需以 MPL 开源。以上为概括,不构成法律意见,请以许可原文为准。

@capgo/nativegeocoder 的下载量有多少?

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

@capgo/nativegeocoder 还在维护吗?

最新版本 8.0.31 发布于 2026/05/11(5 个月前);至今共发布 232 个版本,其中过去 12 个月发布了 37 个;首次发布于 2022/06/29。作者已将其标记为弃用,新项目建议寻找替代方案。