2017-07-19 3 views
0

getLocationから取得した情報をロケーション配列に格納し、その値をfloatに変換します。私はそんなに感謝したいと取得要求に対する配列応答によるループ処理

this.peopleservice.getLocation(ID) 
    .subscribe(data => { 
    this.location = []; 
    for (let item of data) { 
     this.location.push({latitude: parseFloat(item.lat), longitude: parseFloat(item.lng)}); 
    } 
    }); 

答えて

1

使用forループ以下のような

this.peopleservice.getLocation(ID) 
    .subscribe(data =>{this.latcoor = data[x].lat, 
    this.lngcoor=data[x].lng 

    this.lat= parseFloat(this.latcoor); 
    this.lng= parseFloat(this.lngcoor); 

    this.location= [ 
      {latitude:this.lat, longitude:this.lng}, 
     ]; 
    });} 
を格納する方法にループを通るかわかりません
+0

私は正確に動作します。しかし、私は値 – Nouf

関連する問題