快速入门
复制包含安装步骤和该插件完整 Markdown 指南的配置 prompt。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-launch-navigator`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/launch-navigator/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
安装
“安装”章节你可以使用我们的 AI 辅助设置来安装插件。使用以下命令将 Capgo skills 添加到你的 AI 工具中:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins然后使用以下 prompt:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-launch-navigator` plugin in my project.如果你更想手动设置,请运行以下命令安装插件,并按照下方各平台的说明操作:
bun add @capgo/capacitor-launch-navigatorbunx cap sync导入
“导入”章节import { LaunchNavigator } from '@capgo/capacitor-launch-navigator';快速入门
章节标题为“快速入门”import { LaunchNavigator } from '@capgo/capacitor-launch-navigator';
await LaunchNavigator.navigate({ destination: [37.7749, -122.4194], options: { app: 'google_maps' },});示例:让用户选择地图应用
标题为“示例:让用户选择地图应用”的部分const { apps } = await LaunchNavigator.getAvailableApps();// render chooser UI, then navigate with options.app set to the selection示例:先进行地理编码
标题为“示例:先进行地理编码”的部分使用 @capgo/capacitor-nativegeocoder forwardGeocode() 将地址转换为 [lat, lng] 在调用之前 navigate().
常见坑点
章节标题为“常见陷阱”- 仅限坐标: 不支持街道地址
navigate(). - Web 端: 将打开外部地图链接,而非已安装的应用。
- 图标: cache with
getAppIcons()并在用户安装新地图应用时刷新。
API 概览
章节标题:“API 概览”navigate
标题为 “navigate” 的章节通过经纬度导航至指定位置
import { LaunchNavigator } from '@capgo/capacitor-launch-navigator';
await LaunchNavigator.navigate({ destination: [48.8566, 2.3522] });isAppAvailable
“isAppAvailable” 章节检查特定的导航应用是否可用
import { LaunchNavigator, IOSNavigationApp } from '@capgo/capacitor-launch-navigator';
const result = await LaunchNavigator.isAppAvailable({ app: IOSNavigationApp.APPLE_MAPS });console.log(result);getAvailableApps
“getAvailableApps” 章节获取设备上可用的导航应用列表
import { LaunchNavigator } from '@capgo/capacitor-launch-navigator';
const result = await LaunchNavigator.getAvailableApps();console.log(result);getSupportedApps
“getSupportedApps” 章节获取当前平台支持的应用列表
import { LaunchNavigator } from '@capgo/capacitor-launch-navigator';
const result = await LaunchNavigator.getSupportedApps();console.log(result);getDefaultApp
“getDefaultApp” 章节获取默认导航应用的名称
import { LaunchNavigator } from '@capgo/capacitor-launch-navigator';
const result = await LaunchNavigator.getDefaultApp();console.log(result);类型参考
“类型参考” 章节NavigateOptions
“NavigateOptions” 章节导航选项。
export interface NavigateOptions { /** * Starting location coordinates [latitude, longitude] */ start?: [number, number];
/** * Starting location name */ startName?: string;
/** * Destination name (will be ignored since we only support coordinates) */ destinationName?: string;
/** * Transport mode */ transportMode?: TransportMode;
/** * Specific app to launch (if not specified, will use default or prompt) */ app?: IOSNavigationApp | AndroidNavigationApp | string;
/** * Launch mode */ launchMode?: LaunchMode;
/** * Additional parameters specific to certain apps */ extras?: Record<string, any>;
/** * Enable debug logging */ enableDebug?: boolean;}IOSNavigationApp
“IOSNavigationApp” 章节iOS 端可用的导航应用。
export enum IOSNavigationApp { APPLE_MAPS = 'apple_maps', GOOGLE_MAPS = 'google_maps', WAZE = 'waze', CITYMAPPER = 'citymapper', GARMIN_NAVIGON = 'garmin_navigon', TRANSIT_APP = 'transit_app', YANDEX_NAVIGATOR = 'yandex', UBER = 'uber', TOMTOM = 'tomtom', SYGIC = 'sygic', HERE_MAPS = 'here', MOOVIT = 'moovit', LYFT = 'lyft', MAPS_ME = 'mapsme', CABIFY = 'cabify', BAIDU = 'baidu', GAODE = 'gaode', TAXI_99 = '99taxi',}AndroidNavigationApp
Android 端可用的导航应用。Android 端可用的导航应用。
export enum AndroidNavigationApp { GOOGLE_MAPS = 'google_maps', WAZE = 'waze', CITYMAPPER = 'citymapper', UBER = 'uber', YANDEX = 'yandex', SYGIC = 'sygic', HERE_MAPS = 'here', MOOVIT = 'moovit', LYFT = 'lyft', MAPS_ME = 'mapsme', CABIFY = 'cabify', BAIDU = 'baidu', GAODE = 'gaode',}AvailableApp
“AvailableApp” 章节检查 App 是否可用后的结果。
export interface AvailableApp { /** * App identifier */ app: string;
/** * Display name of the app */ name: string;
/** * Whether the app is available on the device */ available: boolean;}TransportMode
“TransportMode” 章节传输模式。
export enum TransportMode { DRIVING = 'driving', WALKING = 'walking', BICYCLING = 'bicycling', TRANSIT = 'transit',}LaunchMode
“LaunchMode” 章节启动模式。
export enum LaunchMode { MAPS = 'maps', TURN_BY_TURN = 'turn_by_turn', GEO = 'geo',}单一事实来源
标题为“单一事实来源”的部分本页面由插件的 src/definitions.ts生成。当上游的公共 API 发生变化时,请重新运行 sync。
从入门指南继续
“从入门指南继续”章节如果你正在使用 快速入门 要规划 dashboard 和 API 操作,请将其连接到 使用 @capgo/capacitor-launch-navigator 用于“使用 @capgo/capacitor-launch-navigator”中的原生能力, API 概览 关于 API Overview 中的实现细节, 简介 关于 Introduction 中的实现细节, API 密钥 有关 API Keys 的实现细节,以及 设备 有关 Devices 的实现细节。