reactjs - 如何设置纬度/经度增量以显示路线坐标?

标签 reactjs algorithm react-native maps

我有这张 map , 使用 react native map 我可以保存 routeCoordinates :[{lat,lng},...] 以显示之后的行。

enter image description here

我想知道/了解的是如何调整区域:

region={{
   latitude:
   longitude: 
   latitudeDelta: 
   longitudeDelta: 
}}

能够在 map 上显示所有的routeCoordinates。也许使用 map 的缩放。 我的区域始终使用起点 (routeCoordinates[0]) 居中。

我需要找到所有可能坐标之间的最大距离吗? 感谢您的帮助。

最佳答案

您可以使用 Google map API 的 map.fitBounds()。这样 map 就会以显示多段线所有坐标的方式缩放。 Documentation Here

const bounds = new google.maps.LatLngBounds();
for (var n = 0; n < myPointsArray.length ; n++){
    bounds.extend(points[n]);
}
map.fitBounds(bounds);

关于reactjs - 如何设置纬度/经度增量以显示路线坐标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57639129/

相关文章:

reactjs - 使用 React + Material UI Card Expander 扩展单个卡片

javascript - 如何唯一标识一个表行?

c++ - 制表哈希和 N3980

java - Java中如何从这个ArrayList中快速知道海量ArrayList中的索引?

algorithm - 最优排类算法

reactjs - 如何在 React js 的 Material UI 选择选项中访问自定义目标属性

javascript - React JS 多输入表单

javascript - react native : How to show collabsible on top of a view

TypeScript 的 import() typeof json

javascript - 如何在另一个调用this.setState()的函数内部的函数中访问组件的状态?