ionic-team / ionic-native-google-maps

Google maps plugin for Ionic Native
Other
221 stars 125 forks source link

Encoding.decodePath() not working #138

Closed cchvuth closed 5 years ago

cchvuth commented 5 years ago

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

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

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://cchvuth@bitbucket.org/cchvuth/tj-ionic-4.git


Giving much information, you are waiting time is less.
Thank you for your cooperation.
wf9a5m75 commented 5 years ago
this.map.one(GoogleMapsEvent.MAP_READY).then(() => {
   Encoding.decodePath('...');
});
cchvuth commented 5 years ago
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')
    });
wf9a5m75 commented 5 years ago

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

cchvuth commented 5 years ago

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)

cchvuth commented 5 years ago

It's working with @ionic-native/google-maps@4.8.2 but not with 4.9 and latest beta

wf9a5m75 commented 5 years ago

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

cchvuth commented 5 years ago

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.

wf9a5m75 commented 5 years ago

Thank you for pointing out. I fixed the code.

HectorVegaD commented 5 years ago

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.

wf9a5m75 commented 5 years ago

In order to contribute, please send a pull request.

danieltanasec commented 3 years ago

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