Ionic native googlemaps decodePath() returns undefined

I tried to do a decodePath on an encoded path using Ionic native googlemaps (cordova-plugin-googlemaps) in an Ionic 3 app. However, the function returns undefined. Here’s my code:

import { Encoding } from "@ionic-native/google-maps";
...
console.log("decoded path", Encoding.decodePath('{~|mAyquxMhEyF'));

I’m using the cordova-plugin-googlemaps 2.2.0-beta-20180117-2320 (multiple maps version) of the plugin.
Is there something wrong that I’m doing in the above code to get undefined as the response from decodePath method?

Thanks for your time.

It seems '{~|mAyquxMhEyF' is too short.

Thanks for your response.
But, https://developers.google.com/maps/documentation/utilities/polylineutility accepts the above encoded path as a valid string and successfully decodes it.

This code worked (without @ionic-native/google-maps)

var encodedPath= '{~|mAyquxMhEyF';

var points = plugin.google.maps.geometry.encoding.decodePath(encodedPath);

var mapDiv = document.getElementById("map_canvas");
var map = plugin.google.maps.Map.getMap(mapDiv, {
  camera: {
    target: points
  }
});

map.addEventListener(plugin.google.maps.event.MAP_READY, function() {

  map.addPolyline({
    "points": points
  });

});

Thanks for your response. Shall I open an issue with Ionic-native?

Why don’t you try to fix the problem of ionic-native, and send it as a pull request?
Source code is fully open, and everybody can send PRs.
Contribute each other, that’s the true open source.

Try this:

$> git clone https://github.com/wf9a5m75/ionic-native

$> cd ionic-native

$> node -v
v9.3.0  <-- important!

$> npm install

$> npm run build

$> cd (your project path)

$> npm uninstall @ionic-native/core @ionic-native/google-maps

$> npm install (path to ionic-native directory)/dist/\@ionic-native/core

$> npm install (path to ionic-native directory)/dist/\@ionic-native/google-maps

$> ionic cordova run android

Hi,

I’m face the same problem, and tried your solution. But now I get the following error:

core.js:1350 ERROR TypeError: Cannot read property 'geometry' of null
    at Function.webpackJsonp.49.Encoding.decodePath (index.js:1357)
    at StationPage.webpackJsonp.181.StationPage.ionViewWillEnter (station.ts:32)
    at ViewController._lifecycle (view-controller.js:486)
    at ViewController._willEnter (view-controller.js:384)
    at Tab.NavControllerBase._willEnter (nav-controller-base.js:780)
    at nav-controller-base.js:673
    at t.invoke (polyfills.js:3)
    at Object.onInvoke (core.js:4629)
    at t.invoke (polyfills.js:3)
    at r.run (polyfills.js:3)

The line that produces the problem is the return of decodePath:

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

Any suggestion? Polyline decoding is important and easier to my app.

It seems the plugin version you installed is too old.

Thanks for your reply.

I’m currently using the latest version

cordova-plugin-googlemaps 2.1.1

As I answered above, you need to build the fixed version from my repo.