ionic-team / ionic-native-google-maps

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

Live updating for Polyline points #233

Closed aligassan closed 4 years ago

aligassan commented 4 years ago

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

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

I am trying to get latitude and longitude from data json api for flight route . My question is how can l do live updating for draw polyline while flight path moving on map .

async ngOnInit() {
    await this.platform.ready();
    await this.loadmap()
    await this.getmarker()

}

loadmap(){
    this.map = GoogleMaps.create('map_canvas')

    if(GoogleMapsEvent.MAP_READY){

        setInterval(()=>{
            this.getmarker()

        },5)
    }
}

async getmarker() {

        this.http.get('xxxxxxxxxxxxxx=' + this.id + '', {}, {})
        .then(data => {
            console.log(data.data+'My data')

            // Track aircraft 

            for (let datas of JSON.parse(data.data).result.response.data.flight['track']) {

                this.points.push({ lng: datas.longitude, lat: datas.latitude });

            }

    ////////// aircraft Polyline path /////

    let polyline: Polyline = this.map.addPolylineSync({
            points: this.points,
            color: '#AA00FF',
            width: 4,
            geodesic: true,

        });

        });

}

The code working fine without issues , also setInterval he is updating data but Polyline he doesn't update flight path on map . any idea please ?

wf9a5m75 commented 4 years ago

Please make a question after reading documents. https://github.com/mapsplugin/cordova-plugin-googlemaps-doc/blob/master/v2.6.0/class/Polyline/README.md#update-the-polyline