Per iniziare
Copia un prompt di configurazione con i passaggi di installazione e la guida markdown completa per questo plugin.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-nativegeocoder`
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/nativegeocoder/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.
Puoi usare il nostro setup assistito dall'IA per installare il plugin. Aggiungi le skill Capgo al tuo strumento di IA usando il seguente comando:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-pluginsPoi usa il seguente prompt:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-nativegeocoder` plugin in my project.Se preferisci la configurazione manuale, installa il plugin eseguendo questi comandi e segui le istruzioni specifiche per piattaforma qui sotto:
npm install @capgo/capacitor-nativegeocodernpx cap syncImporta
Sezione intitolata “Import”import { NativeGeocoder } from '@capgo/capacitor-nativegeocoder';Avvio rapido
Sezione intitolata “Quick start”import { NativeGeocoder } from '@capgo/capacitor-nativegeocoder';
const { addresses } = await NativeGeocoder.reverseGeocode({ latitude: 48.8566, longitude: 2.3522, maxResults: 1,});Esempio: forward geocode di un indirizzo
Sezione intitolata “Esempio: forward geocode di un indirizzo”const { addresses } = await NativeGeocoder.forwardGeocode({ address: '1 Infinite Loop, Cupertino, CA', maxResults: 3,});Errori comuni
Sezione intitolata “Errori comuni”- Chiave API web: il geocoding inverso e diretto sul web richiede una chiave API di Google Geocoding nelle opzioni.
- Locale: imposta
useLocaleodefaultLocalequando visualizzi indirizzi a livello internazionale. - Indirizzi ambigui: solleva
maxResultse lascia che l'utente scelga tra i risultati.
Panoramica API
Sezione intitolata “Panoramica API”reverseGeocode
Sezione “reverseGeocode”Converti latitudine e longitudine in un indirizzo
import { NativeGeocoder } from '@capgo/capacitor-nativegeocoder';
const result = await NativeGeocoder.reverseGeocode({ latitude: 48.8566, longitude: 2.3522,});console.log(result);forwardGeocode
Sezione “forwardGeocode”Converti un indirizzo in latitudine e longitudine
import { NativeGeocoder } from '@capgo/capacitor-nativegeocoder';
const result = await NativeGeocoder.forwardGeocode({ addressString: 'address-string' });console.log(result);Riferimento ai tipi
Sezione: “Type Reference”ReverseOptions
Sezione intitolata “ReverseOptions”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;}Address
Sezione intitolata “Address”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[];}ForwardOptions
Sezione intitolata “ForwardOptions”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;}Fonte di verità
Sezione intitolata “Fonte di verità”Questa pagina è generata dal src/definitions.ts. Riesegui la sync quando il API pubblico cambia upstream.
Continua da Getting Started
Sezione intitolata “Continua da Getting Started”Se stai usando Per iniziare per pianificare le operazioni della dashboard e di API, collegalo a Utilizzo di @capgo/capacitor-nativegeocoder per la funzionalità nativa in Uso di @capgo/capacitor-nativegeocoder, Panoramica API per i dettagli di implementazione in Panoramica di API, Introduzione per i dettagli di implementazione in Introduzione, Chiavi API per i dettagli di implementazione in Chiavi API, e Dispositivi per i dettagli di implementazione in Dispositivi.