Skip to content

@capawesome-team/capacitor-geocoder

Capacitor plugin for handling geocoding and reverse geocoding.

Features

We are proud to offer one of the most complete and feature-rich Capacitor plugins for geocoding and reverse geocoding. Here are some of the key features:

  • πŸ–₯️ Cross-platform: Supports Android, iOS and Web.
  • πŸ“ Geocoding: Convert addresses into geographic coordinates.
  • πŸ—ΊοΈ Reverse Geocoding: Convert geographic coordinates into human-readable addresses.
  • 🌐 Multiple Providers: Support for Google Maps and OpenStreetMap on Web.
  • 🌍 Localization: Customize the locale for geocoding requests.
  • πŸ”’ Configurable Results: Limit the number of addresses returned in reverse geocoding operations.
  • πŸ› οΈ Native APIs: Uses platform-native geocoding services on Android and iOS for reliable and accurate results.
  • πŸ“¦ SPM: Supports Swift Package Manager for iOS.
  • πŸ” Up-to-date: Always supports the latest Capacitor version.
  • ⭐️ Support: Priority support from the Capawesome Team.
  • ✨ Handcrafted: Built from the ground up with care and expertise, not forked or AI-generated.

Missing a feature? Just open an issue and we'll take a look!

Compatibility

Plugin Version Capacitor Version Status
7.x.x >=7.x.x Active support

Demo

Android iOS Web
Android Demo iOS Demo Web Demo

Installation

This plugin is only available to Capawesome Insiders. First, make sure you have the Capawesome npm registry set up. You can do this by running the following commands:

npm config set @capawesome-team:registry https://npm.registry.capawesome.io
npm config set //npm.registry.capawesome.io/:_authToken <YOUR_LICENSE_KEY>

Attention: Replace <YOUR_LICENSE_KEY> with the license key you received from Polar. If you don't have a license key yet, you can get one by becoming a Capawesome Insider.

Next, install the package:

npm install @capawesome-team/capacitor-geocoder universal-geocoder
npx cap sync

Usage

import { Geocoder } from '@capawesome-team/capacitor-geocoder';

const geocode = async () => {
  const result = await Geocoder.geocode({
    address: '1600 Amphitheatre Parkway, Mountain View, CA',
  });
  console.log('Geocode result:', result);
};

const geodecode = async () => {
  const result = await Geocoder.geodecode({
    latitude: 37.422,
    longitude: -122.084,
  });
  console.log('Geodecode result:', result);
};

API

geocode(...)

geocode(options: GeocodeOptions) => Promise<GeocodeResult>

Translate an address into geographic coordinates.

Only available on Android and iOS.

Param Type
options GeocodeOptions

Returns: Promise<GeocodeResult>

Since: 0.0.1


geodecode(...)

geodecode(options: GeodecodeOptions) => Promise<GeodecodeResult>

Translate geographic coordinates into a human-readable address.

Only available on Android and iOS.

Param Type
options GeodecodeOptions

Returns: Promise<GeodecodeResult>

Since: 0.0.1


Interfaces

GeocodeResult

Prop Type Description Since
latitude number The latitude of the geocoded location. 0.0.1
longitude number The longitude of the geocoded location. 0.0.1

GeocodeOptions

Prop Type Description Default Since
address string The address to geocode. 0.0.1
locale string The locale (BCP 47 language tag) to use for the geocoding request. By default, the device's locale is used. 0.0.1
webApiKey string The API key to use for the geocoding service. Only available on Web. 0.0.1
webProvider 'googlemaps' | 'openstreetmaps' The provider to use for the geocoding service. Only available on Web. 'openstreetmaps' 0.0.1
webUserAgent string The User-Agent identifying your application. Only available on the web. 0.0.1

GeodecodeResult

Prop Type Description Since
addresses Address[] The list of addresses that match the given coordinates. The number of addresses returned is limited by the limit option. 0.0.1

Address

Prop Type Description Since
adminArea string The administrative area (e.g. state or province) of the address. 0.0.1
addressLines string[] The lines of the address. 0.0.1
countryCode string The country code of the address. 0.0.1
countryName string The name of the country. 0.0.1
phoneNumber string The phone number of the address. 0.0.1
postalCode string The postal code of the address. 0.0.1
subAdminArea string The sub-administrative area (e.g. county) of the address. 0.0.1
url string The URL of the address. 0.0.1

GeodecodeOptions

Prop Type Description Default Since
latitude number The latitude of the location to reverse geocode. 0.0.1
limit number The maximum number of results to return. 5 0.0.1
longitude number The longitude of the location to reverse geocode. 0.0.1
webApiKey string The API key to use for the geocoding service. Only available on Web. 0.0.1
webProvider 'googlemaps' | 'openstreetmaps' The provider to use for the geocoding service. Only available on Web. 'openstreetmaps' 0.0.1
webUserAgent string The User-Agent identifying your application. Only needed if webProvider is set to openstreetmaps which uses the Nominatim service (see https://operations.osmfoundation.org/policies/nominatim/). The goal is to be able to limit the number of requests per application. Only available on the web. 0.0.1

Changelog

See CHANGELOG.md.

Breaking Changes

See BREAKING.md.

License

See LICENSE.