我有这张 map , 使用 react native map 我可以保存 routeCoordinates :[{lat,lng},...] 以显示之后的行。
我想知道/了解的是如何调整区域:
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/