Ionic-native-google-maps: Encoding.decodePath() not working

Created on 6 Dec 2018  路  11Comments  路  Source: ionic-team/ionic-native-google-maps

I'm submitting a ... (check one with "x")

  • [ ] question
  • [x] any problem or bug report
  • [ ] feature request

If you choose 'problem or bug report', please select OS: (check one with "x")

  • [x] Android
  • [x] iOS
  • [x] Browser

cordova information: (run $> cordova plugin list)

cordova-plugin-device 2.0.2 "Device"
cordova-plugin-googlemaps 2.5.0-beta-20181030-1133 "cordova-plugin-googlemaps"
cordova-plugin-ionic-keyboard 2.1.3 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 2.3.0 "cordova-plugin-ionic-webview"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.2 "StatusBar"
cordova-plugin-whitelist 1.3.3 "Whitelist"

If you use @ionic-native/google-maps, please tell the package.json (only @ionic-native/core and @ionic-native/google-maps are fine mostly)

    "@ionic-native/core": "^5.0.0-beta.21",
    "@ionic-native/google-maps": "^5.0.0-beta.25",

Current behavior:

import {
Encoding
} from '@ionic-native/google-maps';
Encoding.decodePath('o|qeAe}b_StkQirVcwXztA??~bVlcW')
Result:
TypeError: Cannot read property 'decodePath' of undefined
at Function.push../node_modules/@ionic-native/google-maps/index.js.Encoding.decodePath (index.js:741)

Expected behavior:
Returns ILatLng[]

Related code, data or error log (please format your code or data):
https://[email protected]/cchvuth/tj-ionic-4.git

Giving much information, you are waiting time is less.
Thank you for your cooperation.

Most helpful comment

So, I found out that v4.14.0 works as well. I compared the node module and see that on line 2474 of @ionic-native/google-maps/index.js (v4.15.1), you put GoogleMaps.getPlugin().Encoding.decodePath(encoded, precision);
When I change this line to GoogleMaps.getPlugin().geometry.encoding.decodePath(encoded, precision);
it works like a charm.

All 11 comments

```
this.map.one(GoogleMapsEvent.MAP_READY).then(() => {
Encoding.decodePath('...');
});
````

this.map.one(GoogleMapsEvent.MAP_READY).then(() => {
   Encoding.decodePath('...');
});

It returns the same error

    this.map = GoogleMaps.create('map_canvas', {
      camera: {
        target: {
          lat: this.lat,
          lng: this.lon
        },
        zoom: 18,
        tilt: 30
      }
    })
    this.map.one(GoogleMapsEvent.MAP_READY).then(() => {
      Encoding.decodePath('o|qeAe}b_StkQirVcwXztA??~bVlcW')
    });

Unfortunately, I'm terrible busy this week.
You need to wait until I'm ready, or please inspect by yourself.

Unfortunately, I'm terrible busy this week.
You need to wait until I'm ready, or please inspect by yourself.

It used to work correctly around 5 months ago, now the same code doesn't work anymore, even on non-beta version (tried on ionic 3 and ionic 4)

It's working with @ionic-native/[email protected] but not with 4.9 and latest beta

Good job 馃憤
Find out the problem position, then could you send a pull request?

So, I found out that v4.14.0 works as well. I compared the node module and see that on line 2474 of @ionic-native/google-maps/index.js (v4.15.1), you put GoogleMaps.getPlugin().Encoding.decodePath(encoded, precision);
When I change this line to GoogleMaps.getPlugin().geometry.encoding.decodePath(encoded, precision);
it works like a charm.

Thank you for pointing out. I fixed the code.

Hey the code still isn't fixed from what I can tell. You changed it to:

Partial / Incorrect Fix:
return GoogleMaps.getPlugin().encoding.decodePath(encoded, precision); - just making 'e' lowercase, you still need to add the '.geometry.e' part like cchvuth pointed out.

Full Fix:
return GoogleMaps.getPlugin().geometry.encoding.decodePath(encoded, precision);

Got lost for a while after applying your changes, decided to console log the .getPlugin() call and noticed encoding is inside geometry object. Anyway I might be wrong, I'm still new to trying to understand complex code.

In order to contribute, please send a pull request.

This issue is still with us in version 5.5.0.
Only GoogleMaps.getPlugin().geometry.encoding.decodePath(encoded) works.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

manumarquez picture manumarquez  路  11Comments

mcastets picture mcastets  路  4Comments

MikeWoots picture MikeWoots  路  10Comments

piernik picture piernik  路  3Comments

chandraahmad picture chandraahmad  路  9Comments