capacitor-map-launcher
v8.0.0
Published
Opens coordinates in native map apps
Readme
capacitor-map-launcher
Opens coordinates in native map apps (Google Maps, Apple Maps, Waze, OsmAnd, HERE, Baidu, … — see MapType).
Requires Capacitor 8, iOS 15+ and Android API 24+. The package is ESM only.
Install
npm install capacitor-map-launcher
npx cap synciOS
iOS only reports apps whose URL scheme is declared in your app's ios/App/App/Info.plist. Add the schemes of the maps you want to detect (iOS allows at most 50 entries):
<key>LSApplicationQueriesSchemes</key>
<array>
<string>comgooglemaps</string>
<string>iosamap</string>
<string>baidumap</string>
<string>waze</string>
<string>yandexnavi</string>
<string>yandexmaps</string>
<string>citymapper</string>
<string>mapswithme</string>
<string>osmandmaps</string>
<string>dgis</string>
<string>qqmap</string>
<string>here-location</string>
<string>tomtomgo</string>
<string>tomtomgofleet</string>
<string>com.sygic.aura</string>
<string>copilot</string>
<string>nmap</string>
<string>kakaomap</string>
<string>tmap</string>
<string>szn-mapy</string>
</array>Apple Maps is always available and needs no entry.
Android
No setup required. The plugin declares the necessary <queries> for package visibility.
Usage
import { MapLauncher, MapType, showMarker } from 'capacitor-map-launcher';
const { value: maps } = await MapLauncher.getInstalledMaps();
// Coordinates are [longitude, latitude]
await showMarker(MapType.GOOGLE, [13.377348, 52.516323], 'Brandenburg Gate');showMarker(mapType, coords, title?, description?, zoom = 16) builds the app-specific deep link and opens it. Not every app supports a title, description or zoom level.
Failed calls reject with one of these codes:
| Code | Reason |
| ------------------- | ---------------------------------------------------------- |
| MAP_NOT_AVAILABLE | The app is not installed or not supported on this platform |
| INVALID_URL | The generated URL could not be parsed |
| OPEN_FAILED | The OS refused to open the app |
API
getInstalledMaps()
getInstalledMaps() => Promise<{ value: MapModel[]; }>Lists the supported map apps that are installed on the device.
On iOS, an app is only detected if its URL scheme is listed under
LSApplicationQueriesSchemes in the app's Info.plist.
Returns: Promise<{ value: MapModel[]; }>
isMapAvailable(...)
isMapAvailable(options: { mapType: MapType; }) => Promise<{ value: boolean; }>Checks whether the given map app is installed.
| Param | Type |
| ------------- | --------------------------------------------------------- |
| options | { mapType: MapType; } |
Returns: Promise<{ value: boolean; }>
showMarker(...)
showMarker(options: { mapType: MapType; url: string; lat: number; lon: number; title?: string; description?: string; }) => Promise<void>Opens a marker in the given map app.
Prefer the exported showMarker() helper, which builds the app-specific url for you.
Rejects with code MAP_NOT_AVAILABLE if the app is not installed.
| Param | Type |
| ------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| options | { mapType: MapType; url: string; lat: number; lon: number; title?: string; description?: string; } |
Interfaces
MapModel
| Prop | Type | Description |
| ----------------- | ------------------------------------------- | -------------------------------------------------- |
| mapType | MapType | |
| mapName | string | Human-readable name, e.g. "Google Maps". |
| packageName | string | Android package name. Only set on Android. |
| urlPrefix | string | URL scheme used to detect the app, e.g. "waze://". |
Enums
MapType
| Members | Value | Description |
| ------------------- | ---------------------------- | ------------------------------------------ |
| APPLE | 'apple' | Apple Maps. Only available on iOS. |
| GOOGLE | 'google' | Google Maps |
| GOOGLE_GO | 'googleGo' | Google Maps Go. Only available on Android. |
| AMAP | 'amap' | Amap (Gaode Maps) |
| BAIDU | 'baidu' | Baidu Maps |
| WAZE | 'waze' | Waze |
| YANDEX_MAPS | 'yandexMaps' | Yandex Maps |
| YANDEX_NAVI | 'yandexNavi' | Yandex Navi |
| CITYMAPPER | 'citymapper' | Citymapper |
| MAPSWITHME | 'mapswithme' | MAPS.ME |
| OSMAND | 'osmand' | OsmAnd |
| OSMANDPLUS | 'osmandplus' | OsmAnd+. Only available on Android. |
| DOUBLE_GIS | 'doubleGis' | 2GIS |
| TENCENT | 'tencent' | Tencent (QQ Maps) |
| HERE | 'here' | HERE WeGo |
| PETAL | 'petal' | Petal Maps. Only available on Android. |
| TOMTOMGO | 'tomtomgo' | TomTom Go |
| TOMTOMGOFLEET | 'tomtomgofleet' | TomTom Go Fleet |
| COPILOT | 'copilot' | CoPilot |
| SYGIC_TRUCK | 'sygicTruck' | Sygic Truck |
| FLITSMEISTER | 'flitsmeister' | Flitsmeister. Only available on Android. |
| TRUCKMEISTER | 'truckmeister' | Truckmeister. Only available on Android. |
| NAVER | 'naver' | Naver Map |
| KAKAO | 'kakao' | KakaoMap |
| TMAP | 'tmap' | TMAP |
| MAPY_CZ | 'mapyCz' | Mapy.cz |
