Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to geocode destination address to coordinates: Index 0 out of range [0..0) error (Android) #281

Open
4 of 5 tasks
ryaa opened this issue Nov 7, 2024 · 1 comment

Comments

@ryaa
Copy link
Contributor

ryaa commented Nov 7, 2024

Bug report

CHECKLIST

  • I have reproduced the issue using the example project or provided the necessary information to reproduce the issue.

I could not build/run the Ionic4Example using the provided instructions because npm install fails with the below error

alexryltsov@Alexs-MacBook-Pro-2 Ionic4Example % npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/rxjs
npm ERR!   rxjs@"~6.3.3" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer rxjs@"^5.5.0 || ^6.5.0" from @ionic-native/[email protected]
npm ERR! node_modules/@ionic-native/core
npm ERR!   @ionic-native/core@"^5.0.0" 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! 
npm ERR! 
npm ERR! For a full report see:
npm ERR! /Users/alexryltsov/.npm/_logs/2024-11-07T15_14_01_315Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in: /Users/alexryltsov/.npm/_logs/2024-11-07T15_14_01_315Z-debug-0.log
  • I have checked that no similar issues (open or closed) already exist.

Current behavior:
When on Android platform the navigate method is invoked, and the user chooses Google Maps mapping app, the app tries to geocoder the address to lat/lng. However, if this address can not be geocoded (for example, the address is unknown city unknown street unknown house which invokes google maps geocoder using this URL https://maps.google.com/maps/api/geocode/json?address=unknown city unknown street unknown house&sensor=false&key=<API_KEY>) and the google service returns the below response

{
   "results" : [],
   "status" : "ZERO_RESULTS"
}

the app fails with the error Unable to geocode destination address to coordinates: Index 0 out of range [0..0 because it always expect the results array to contain the first element - see https://github.com/dpa99c/phonegap-launch-navigator/blob/master/src/android/lib/LaunchNavigator.java#L1704

Expected behavior:
No error occurs when address can not be geocoded

Steps to reproduce:
See above

Screenshots
N/A

Environment information

alexryltsov@Alexs-MacBook-Pro-2 bugfix-479-unable-to-geocode-destination-address-to-coordinates-index-0-out-of-range-00 % ionic info

Ionic:

   Ionic CLI                     : 7.2.0 (/Users/alexryltsov/.nvm/versions/node/v20.11.1/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 8.1.0
   @angular-devkit/build-angular : 17.3.6
   @angular-devkit/schematics    : 17.3.6
   @angular/cli                  : 17.3.6
   @ionic/angular-toolkit        : 11.0.1

Capacitor:

   Capacitor CLI      : 6.0.0
   @capacitor/android : 6.0.0
   @capacitor/core    : 6.0.0
   @capacitor/ios     : 6.0.0

Utility:

   cordova-res : not installed globally
   native-run  : 2.0.1

System:

   NodeJS : v20.11.1 (/Users/alexryltsov/.nvm/versions/node/v20.11.1/bin/node)
   npm    : 10.5.0
   OS     : macOS Unknown

Related code:

            const options: LaunchNavigatorOptions = {};
            if (this.platform.is('android')) {
                options.launchModeGoogleMaps = window.launchnavigator.LAUNCH_MODE.GEO;
            }
            try {
                await this.launchNavigator.navigate("unknown city unknown street unknown house", options);
            } catch (error) {
            }

Console output
N/A

Other information:
The plugin should be able to handle the use case when geocoding returns no result

@ryaa
Copy link
Contributor Author

ryaa commented Nov 11, 2024

The required fix has been provided in this PR #282

dpa99c added a commit that referenced this issue Nov 11, 2024
…rns-no-result

bugfix: Unable to geocode destination address to coordinates: Index 0 out of range [0..0) error (Android) #281
ryaa added a commit to ryaa/phonegap-launch-navigator that referenced this issue Nov 11, 2024
… out of range [0..0) error (Android) dpa99c#281

Changes:
- fixed a minor typo
dpa99c added a commit that referenced this issue Nov 11, 2024
…rns-no-result

bugfix: Unable to geocode destination address to coordinates: Index 0 out of range [0..0) error (Android) #281
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant