Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
React native 如何制作<;多段线/>;使用HERE API在react native maps中跟随道路_React Native_Here Api_Polyline_React Native Maps - Fatal编程技术网

React native 如何制作<;多段线/>;使用HERE API在react native maps中跟随道路

React native 如何制作<;多段线/>;使用HERE API在react native maps中跟随道路,react-native,here-api,polyline,react-native-maps,React Native,Here Api,Polyline,React Native Maps,我能够向这里的API发出请求并得到响应,我将所有的航路点从航段放到一个数组(纬度和经度)中,它确实画了一条多段线,但它不沿着道路。它只是穿过建筑物等 这是我的多段线组件: this.state.route是一个坐标数组,我得到如下结果: axios.get(`https://route.api.here.com/routing/7.2/calculateroute.json?app_id={myappid}&app_code={myappcode}&waypoint0=geo!${from_

我能够向这里的API发出请求并得到响应,我将所有的航路点从航段放到一个数组(纬度和经度)中,它确实画了一条多段线,但它不沿着道路。它只是穿过建筑物等

这是我的多段线组件:


this.state.route是一个坐标数组,我得到如下结果:

axios.get(`https://route.api.here.com/routing/7.2/calculateroute.json?app_id={myappid}&app_code={myappcode}&waypoint0=geo!${from_lat},${from_long}&waypoint1=geo!${to_lat},${to_long}&mode=最快;自行车;交通:禁用`)。然后((响应)=>{
日志(response.data.response.route);
response.data.response.route[0]。leg[0]。maneuver.map((m)=>{
路线坐标推送({纬度:m.position.lation,经度:m.position.longitude});
})
控制台日志(路线坐标);
this.props.navigation.navigate('ShowMap'{
地点:chosenSpot,
路线:路线坐标,
});  
}).catch((错误)=>{
console.log(错误);
})
然后我将这个数组传递到我的屏幕上,并将其作为
路由
置于我的状态

我希望它能在道路上画一条多段线,而不是在建筑物上

下面是一幅图像,向您展示了它的外观(请注意,蓝线仅用于覆盖道路名称,与绘制多段线无关):

请向CalculatorOute rest api添加一个附加参数: legatorites=shape

然后RESTAPI将返回包含道路沿线点的shape对象

https://route.api.here.com/routing/7.2/calculateroute.json?app_id={myappid}&app_code={myappcode}&waypoint0=geo!${from_lat},${from_long}&waypoint1=geo!${to_lat},${to_long}&mode=fastest;bicycle;traffic:disabled&legAttributes=shape
请参阅文档中的致谢词。

谢谢您的帮助,但它并没有解决问题。好吧,我第一次误解了答案,但现在我看到了“形状”数组。我该怎么处理它?