Mer*_*rym 1 location flutter google-maps-flutter
我正在我的应用程序中做一个应用程序。我正在使用谷歌地图 flutter,并且遇到了有关滚动的问题。当我滚动地图时,我想获取地图的中心点(长、纬度),也就是说,如果我滚动地图并停在某个位置,它将获取中心的位置点。
谁能建议如何解决这个问题?这可能非常有帮助,提前谢谢您..
我会得到屏幕的边界,然后找到这些边界的中心。如果你有一个用于 GoogleMap 的 GoogleMapController,只需使用如下函数:
getCenter() async {
LatLngBounds bounds = await mapsController.getVisibleRegion();
LatLng center = LatLng(
(bounds.northeast.latitude + bounds.southwest.latitude) / 2,
(bounds.northeast.longitude + bounds.southwest.longitude) / 2,
);
return center;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1893 次 |
| 最近记录: |