Polyline are not draw in the map in ionic3?

Hi guys this is my first post in this site, I’m working in a App in Ionic 3 that shows current position in the map . as well click start track button we have to add polyline between the lat and lang. I want to draw a Polyline between this markers but i haven’t succeed yet. i know there are some ways to draw polylines my idea is to extract the lat, long coordinates of the marker, save them in a array and then set that as a “path” to draw the Polyline but im having problems with the creation of the array like in the comment below. here is my code:


  startTracking() {

    this.isTracking = true;
    this.trackedRoute = [];
 
    this.positionSubscription = this.geolocation.watchPosition()
      .pipe(
        filter((p) => p.coords !== undefined) //Filter Out Errors
      ).subscribe(data => {
        setTimeout(() => {
          this.trackedRoute.push({ lat: data.coords.latitude, lng: data.coords.longitude });
          this.redrawPath(this.trackedRoute);
        }, 0);
      });
  }
 
  redrawPath(path) {
    if (this.currentMapTrack) {
      this.currentMapTrack.setMap(null);
    }
 
    if (path.length > 1) {
      this.currentMapTrack = new google.maps.Polyline({
        path: path,
        geodesic: true,
        strokeColor: '#ff00ff',
        strokeOpacity: 1.0,
        strokeWeight: 3
      });
      this.currentMapTrack.setMap(this.map);
    }
  }```


Html section 
``` <div #map id="map"></div>
1 Like

I have the same problem