gpt4 book ai didi

android - 在我的 flutter 谷歌地图应用程序上绘制带有折线的路线时如何缩小和动画相机

转载 作者:行者123 更新时间:2023-12-03 04:45:26 25 4
gpt4 key购买 nike

我 flutter 的谷歌地图应用程序在两点之间绘制了一条路线,但通常这两点不适合屏幕,我希望用户能够看到这两点,例如当用户选择他的位置并且应用程序从他的位置绘制路线时到他的目的地,它应该在屏幕上可见并适合,希望有动画相机以获得流畅的感觉,任何想法,请谢谢

最佳答案

您需要使用 CameraUpdate.newLatLngBounds()使两个点在屏幕内可见。

示例用法:

mapController.animateCamera(
CameraUpdate.newLatLngBounds(
LatLngBounds(
southwest: LatLng(
fromLocationLatLng.latitude <= toLocationLatLng.latitude
? fromLocationLatLng.latitude
: toLocationLatLng.latitude,
fromLocationLatLng.longitude <= toLocationLatLng.longitude
? fromLocationLatLng.longitude
: toLocationLatLng.longitude),
northeast: LatLng(
fromLocationLatLng.latitude <= toLocationLatLng.latitude
? toLocationLatLng.latitude
: fromLocationLatLng.latitude,
fromLocationLatLng.longitude <= toLocationLatLng.longitude
? toLocationLatLng.longitude
: fromLocationLatLng.longitude)),100),
);

您需要记住以下使用的条件是上面的示例。
'southwest.latitude <= northeast.latitude': is not true.
否则会抛出错误。

更新:

如果您查看 Cardinal Direction , 每个方向都有特定的界限/范围
             North (+90)
|
(-180) West ———+——— East (+180)
|
South (-90)

对于下面的示例
southWest = Latlng(-7.12725588946924, 159.14) 实际上比 northEast = Latlng(70.0415297179124, 24.855900000000005) 更东。

并且缩放将超出边界,即到给定点的东边而不是西南边。您可以使用此交互式网站 https://boundingbox.klokantech.com/ 了解有关此框的更多信息

之后的以上信息更新 取自 https://github.com/Leaflet/Leaflet/issues/4919

关于android - 在我的 flutter 谷歌地图应用程序上绘制带有折线的路线时如何缩小和动画相机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62422436/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com