0

我尝试为汽车制作一个跟踪应用程序。屏幕截图上的市场是跟踪的地理位置点。黄线是我使用跟踪的原始地理位置点时绘制的线,紫色线是使用 Google 的 Roads API 绘制的。为什么紫色线不完全在路上?我怎样才能做到这一点?

我从 backgroundgeolocation ( https://github.com/mauron85/react-native-background-geolocation ) 获得的跟踪点,因为我使用 ionic 并且在后台也需要它。

这是我的roadsAPI调用:位置是一个经纬度字符串,语法正确,例如:“lat,lng|lat,lng|......”

 async getRoadAPI(locations: string){
     let tracked = [];
      await axios.get('https://roads.googleapis.com/v1/snapToRoads?path='+locations+'&interpolate=true&key=secret').then(function (response) {  
        response.data['snappedPoints'].forEach(data => {
          tracked.push({ lat: data.location.latitude, lng: data.location.longitude }) 
        });  
      }).catch(function (error) {
        console.log(error); 
      });
      this.trackedRoute = tracked
    }

在此处输入图像描述

4

0 回答 0