Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70434

Promise.all().then not called in background

$
0
0

@adappter wrote:

Hello all,

I have currently a confusing problem.

I’m using the Google Maps Plugin to rotate a Polygon. This is what my code looks like:

 private rotatePolygon(polygon: Polygon, latLngArray: ILatLng[], angle: number) {
    const pointsPromise = [];

    latLngArray.forEach((latLng: ILatLng) => {
      const point = this.map.fromLatLngToPoint(latLng);
      pointsPromise.push(point);
    });

    const coordsPromise = [];
    Promise.all(pointsPromise).then((results: any[]) => {
      this.map.fromLatLngToPoint(latLngArray[0]).then((originResult: any[]) => {
        const originPoint = {x: originResult[0], y: originResult[1]};
        results.forEach((points: number[]) => {
          const point = {x: points[0], y: points[1]};
          const rotatePoints = this.rotatePoint(point, originPoint, angle);
          const rotatedLatLng = this.map.fromPointToLatLng([rotatePoints.x, rotatePoints.y]);
          coordsPromise.push(rotatedLatLng);
        });

        Promise.all(coordsPromise).then((result: ILatLng[]) => {
          console.log("result:", result);
          polygon.setPoints(result);
        });
      });
    });
  }

When the App is active, the rotation works well. But as soon as the App is in the background the Promise.all Callback is not called anymore. This happens only on Android.

Do you guys know, what I could do?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70434

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>