cordova-plugin-googlemaps: Polyline not displaying

I’m submitting a … (check one with “x”)

  • [ x ] question
  • any problem or bug report

OS: (check one with “x”)

  • [ x ] Android
  • iOS
  • Browser

Current behavior: I am implementing the map and it displays successfully with the marker and info window. But when I attempt to add a polyline to the map, it doesn’t display anything and I don’t seem to understand what the reason is. This is the code that am using below.

   directionsService.route({
        origin: new LatLng(this.origin.lat, this.origin.lng),
        destination: new LatLng(this.destination.lat, this.destination.lng),
        travelMode: google.maps.TravelMode['DRIVING']
    }, (res, status) => {

      if(status == google.maps.DirectionsStatus.OK){
          // decode overview_polyline from direction services.
          let decodedPoints = new google.maps.geometry.encoding.decodePath(res.routes[0].overview_polyline);

          let map = GoogleMaps.create("map", {
            camera: {
              target: decodedPoints
            }
          });

          map.addPolylineSync({
              points: decodedPoints,
              color: '#228b22',
              width: 6, 
              geodesic: true
          });

      } else {
          console.warn(status);
      }

    });
`

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 30 (14 by maintainers)

Most upvoted comments

After searching online, I finally found a solution that solved my problem here https://github.com/ionic-team/ionic-native-google-maps/issues/138#issuecomment-445430033 Thanks for your help and time. And thanks for creating the plugin, it’s very awesome.