谷歌地图的重复折线

时间:2019-07-21 10:49:25

标签: angular google-maps polyline

我有一个使用Google地图的Ionic应用程序。我正在尝试从数据json api获取飞行路线的纬度和经度。使用setInterval更新飞行路线的点时,会得到飞行路线的副本。

我的代码

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,

        });


        });

}

0 个答案:

没有答案