GithubHelp home page GithubHelp logo

cap-go / capacitor-nativegeocoder Goto Github PK

View Code? Open in Web Editor NEW
19.0 2.0 4.0 722 KB

Capacitor plugin for native forward and reverse geocoding

License: MIT License

Ruby 2.65% Java 38.37% Swift 31.52% Objective-C 2.09% JavaScript 1.93% TypeScript 23.45%
capacitor capacitor-plugin geocoding android swift

capacitor-nativegeocoder's Introduction

@capgo/nativegeocoder

Capgo - Instant updates for capacitor

Capacitor plugin for native forward and reverse geocoding

Install

npm install @capgo/nativegeocoder
npx cap sync

then import this into your code:

import { NativeGeocoder } from '@capgo/nativegeocoder';

iOS

Apple requires privacy descriptions to be specified in Info.plist for location information:

  • NSLocationAlwaysUsageDescription (Privacy - Location Always Usage Description)
  • NSLocationWhenInUseUsageDescription (Privacy - Location When In Use Usage Description)

Read about Configuring Info.plist in the iOS Guide for more information on setting iOS permissions in Xcode

Android

This API requires the following permissions be added to your AndroidManifest.xml:

<!-- Geolocation API -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature android:name="android.hardware.location.gps" />

API

reverseGeocode(...)

reverseGeocode(options: ReverseOptions) => any

Convert latitude and longitude to an address

Param Type
options ReverseOptions

Returns: any

Since: 0.0.1


forwardGeocode(...)

forwardGeocode(options: ForwardOptions) => any

Convert an address to latitude and longitude

Param Type
options ForwardOptions

Returns: any

Since: 0.0.1


Interfaces

ReverseOptions

Prop Type Description
latitude number latitude is a number representing the latitude of the location.
longitude number longitude is a number representing the longitude of the location.
useLocale boolean Localise the results to the given locale.
defaultLocale string locale is a string in the format of language_country, for example en_US.
maxResults number Max number of results to return.
apiKey string Only used for web platform to use google api

Address

Prop Type
latitude number
longitude number
countryCode string
countryName string
postalCode string
administrativeArea string
subAdministrativeArea string
locality string
subLocality string
thoroughfare string
subThoroughfare string
areasOfInterest {}

ForwardOptions

Prop Type Description
addressString string address is a string of the address to be geocoded.
useLocale boolean Localise the results to the given locale.
defaultLocale string locale is a string in the format of language_country, for example en_US.
maxResults number Max number of results to return.
apiKey string Only used for web platform to use google api

Thanks

To @sebastianbaar and his work on cordova-plugin-nativegeocoder what he made was very inspiring

capacitor-nativegeocoder's People

Contributors

actions-user avatar github-actions[bot] avatar raddishiow avatar renovate[bot] avatar riderx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

capacitor-nativegeocoder's Issues

results do not include formatted_address?

I'm examining the results form this plugin and while I get a bunch of address components, there's no formatted_address field. when examining the network traffic through web, I see that the response indeed includes formatted_address but looking at the source code, I think this plugin doesn't forward that info.

is there a thinking behind this? I could simply reconstruct the formatted address from the address components that are returned, but why not just pass through formatted_address if it's already given?

Error on Native with certain addresses

When searching for certain addresses, the forward geocoding works on web but fail on native.

In this example, "Cape Town International Airport (CPT), Matroosfontein, Cape Town, South Africa" worked on Web but fail on native.

Screenshot 2023-07-11 at 18 13 25

TypeError

Not sure if it is linked to the plugin or my implementation of it (with TypeScript) but I receive this error when I call NativeGeocoding.forwardGeocode():

Error: TypeError: Cannot read properties of undefined (reading 'slice')
at web.ts:105:1
at async createMap (index.tsx:54:1)

result_type parameter prevents returning any addresses

I just tried using this plugin to reverse geocode on web and passed in the required parameters: latitude, longitude, and apiKey. however, it returned 0 addresses. I then manually put the generated url into my browser. with result_type=street_address, there are indeed no results, but without that parameter, I get several results. it seems they have types like bar, establishment, and store. they just don't have street_address.

is it possible to remove this parameter or at least make it a configurable option?

Capacitor 4 compatibility

When trying to install the plugin on a Capacitor 4 app, the following error occurs:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: @capacitor/[email protected]
npm ERR! node_modules/@capacitor/core
npm ERR!   dev @capacitor/core@"^4.0.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer @capacitor/core@"^3.0.0" from @capgo/[email protected]
npm ERR! node_modules/@capgo/nativegeocoder
npm ERR!   @capgo/nativegeocoder@"*" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 

missing ? in URL (forwardGeocoding)

It seems there is a missing ? in the url called, in the forwardGeocoding.

When trying, it calls https://maps.googleapis.com/maps/api/geocode/jsonaddress= instead of https://maps.googleapis.com/maps/api/geocode/json?address=

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • fix(deps): update dependency com.android.tools.build:gradle to v8.4.0
  • chore(deps): lock file maintenance

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

cocoapods
ios/Podfile
github-actions
.github/workflows/build.yml
  • actions/checkout v3
  • pnpm/action-setup v2
  • actions/setup-node v3
  • actions/setup-java v3
  • actions/checkout v3
  • pnpm/action-setup v2
  • actions/setup-node v3
  • actions/checkout v3
  • pnpm/action-setup v2
  • actions/setup-node v3
  • JS-DevTools/npm-publish v1
  • JS-DevTools/npm-publish v1
.github/workflows/bump_version.yml
  • actions/checkout v3
  • pnpm/action-setup v2
  • actions/setup-node v3
  • actions/checkout v3
  • pnpm/action-setup v2
  • actions/setup-node v3
.github/workflows/test.yml
  • actions/checkout v3
  • pnpm/action-setup v2
  • actions/setup-node v3
  • actions/setup-java v3
  • actions/checkout v3
  • pnpm/action-setup v2
  • actions/setup-node v3
  • actions/checkout v3
  • pnpm/action-setup v2
  • actions/setup-node v3
gradle
android/gradle.properties
android/settings.gradle
android/build.gradle
  • com.android.tools.build:gradle 8.2.2
gradle-wrapper
android/gradle/wrapper/gradle-wrapper.properties
  • gradle 8.7
npm
example/package.json
package.json
  • @capacitor/android ^6.0.0
  • @capacitor/cli ^6.0.0
  • @capacitor/core ^6.0.0
  • @capacitor/docgen ^0.2.2
  • @capacitor/ios ^6.0.0
  • @ionic/eslint-config ^0.3.0
  • @ionic/prettier-config ^4.0.0
  • @ionic/swiftlint-config ^1.1.2
  • @typescript-eslint/eslint-plugin ^7.8.0
  • @typescript-eslint/parser ^7.8.0
  • eslint ^9.1.1
  • eslint-plugin-import ^2.29.1
  • husky ^9.0.11
  • prettier ^3.2.5
  • prettier-plugin-java ^2.6.0
  • rimraf ^5.0.5
  • rollup ^4.17.1
  • swiftlint ^1.0.2
  • typescript ^5.4.5
  • @capacitor/core ^6.0.0

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.