メインコンテンツへスキップ

スタートガイド

GitHub

AIアシストによるセットアップでプラグインをインストールできます。以下のコマンドを使用して、お使いのAIツールに Capgo のスキルを追加してください:

ターミナル
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

次に、以下のプロンプトを使用します:

Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-nativegeocoder` plugin in my project.

手動セットアップを希望する場合は、以下のコマンドを実行してプラグインをインストールし、下記のプラットフォーム別の手順に従ってください:

ターミナル
npm install @capgo/capacitor-nativegeocoder
npx cap sync
import { NativeGeocoder } from '@capgo/capacitor-nativegeocoder';
import { NativeGeocoder } from '@capgo/capacitor-nativegeocoder';
const { addresses } = await NativeGeocoder.reverseGeocode({
latitude: 48.8566,
longitude: 2.3522,
maxResults: 1,
});

例:住所をフォワードジオコーディングする

「例:住所をフォワードジオコーディングする」というセクション
const { addresses } = await NativeGeocoder.forwardGeocode({
address: '1 Infinite Loop, Cupertino, CA',
maxResults: 3,
});
  • Web 用 API キー:Web でのリバースジオコーディングとフォワードジオコーディングには、options に Google Geocoding API キーが必要です。
  • ロケール:設定 useLocale または defaultLocale するのは、国際的な住所表示を行う場合です。
  • 曖昧な住所: 発生 maxResults ユーザーに候補から選択させます。

緯度・経度を住所に変換

import { NativeGeocoder } from '@capgo/capacitor-nativegeocoder';
const result = await NativeGeocoder.reverseGeocode({
latitude: 48.8566,
longitude: 2.3522,
});
console.log(result);

住所を緯度・経度に変換

import { NativeGeocoder } from '@capgo/capacitor-nativegeocoder';
const result = await NativeGeocoder.forwardGeocode({ addressString: 'address-string' });
console.log(result);
export interface ReverseOptions {
/**
* latitude is a number representing the latitude of the location.
*/
latitude: number;
/**
* longitude is a number representing the longitude of the location.
*/
longitude: number;
/**
* Localise the results to the given locale.
*/
useLocale?: boolean;
/**
* locale is a string in the format of language_country, for example en_US.
*/
defaultLocale?: string;
/**
* Max number of results to return.
*/
maxResults?: number;
/**
* Only used for web platform to use google api
*/
apiKey?: string;
/**
* Only used for web platform to use google api
*/
resultType?: string;
}
export interface Address {
latitude: number;
longitude: number;
countryCode: string;
countryName: string;
postalCode: string;
administrativeArea: string;
subAdministrativeArea: string;
locality: string;
subLocality: string;
thoroughfare: string;
subThoroughfare: string;
areasOfInterest: string[];
}
export interface ForwardOptions {
/**
* address is a string of the address to be geocoded.
*/
addressString: string;
/**
* Localise the results to the given locale.
*/
useLocale?: boolean;
/**
* locale is a string in the format of language_country, for example en_US.
*/
defaultLocale?: string;
/**
* Max number of results to return.
*/
maxResults?: number;
/**
* Only used for web platform to use google api
*/
apiKey?: string;
}

このページはプラグインの src/definitions.tsから生成されています。upstream で公開 API が変更されたら、再度 sync を実行してください。

Getting Startedの続きを進める

「Getting Started からの続き」セクション

使用している場合 スタートガイド ダッシュボードと API の運用を計画するには、これを次と連携させます @capgo/capacitor-nativegeocoder の使用方法 「@capgo/capacitor-nativegeocoder の使用方法」のネイティブ機能では、 API の概要 「API の概要」の実装の詳細については、 はじめに 「はじめに」における実装の詳細については、 API キー および「API Keys」の実装の詳細については、 デバイス 実装の詳細については Devices を参照してください。