Flutter 如何在地图中的两个标记之间进行缩放

Flutter 如何在地图中的两个标记之间进行缩放,flutter,dart,maps,Flutter,Dart,Maps,我尝试在带有颤振的地图中放大两个标记,但在颤振边界中找不到方法 getRouteCoordinates(_initialPosition, destination); *LatLngBounds bound = LatLngBounds(northeast: initialPosition,southwest: destination); //mapController.getVisibleRegion(); CameraUpdate u2 = CameraUpd

我尝试在带有颤振的地图中放大两个标记,但在颤振边界中找不到方法

  getRouteCoordinates(_initialPosition, destination);
  *LatLngBounds bound = LatLngBounds(northeast: initialPosition,southwest: destination);


      //mapController.getVisibleRegion();
    CameraUpdate u2 = CameraUpdate.newLatLngBounds(bound, 10);
    this.mapController.animateCamera(u2).then((void v){
      check(u2,this.mapController);
    });


  void check(CameraUpdate u, GoogleMapController c) async {
    c.animateCamera(u);
    mapController.animateCamera(u);
    LatLngBounds l1=await c.getVisibleRegion();
    LatLngBounds l2=await c.getVisibleRegion();
    print(l1.toString());
    print(l2.toString());
    if(l1.southwest.latitude==-90 ||l2.southwest.latitude==-90)
      check(u, c);
   }

首先,从您的地质点制作一个列表,并制作一个函数来选择边界点

LatLngBounds boundsFromLatLngList(List<LatLng> list) {
assert(list.isNotEmpty);
double x0, x1, y0, y1;
for (LatLng latLng in list) {
  if (x0 == null) {
    x0 = x1 = latLng.latitude;
    y0 = y1 = latLng.longitude;
  } else {
    if (latLng.latitude > x1) x1 = latLng.latitude;
    if (latLng.latitude < x0) x0 = latLng.latitude;
    if (latLng.longitude > y1) y1 = latLng.longitude;
    if (latLng.longitude < y0) y0 = latLng.longitude;
  }
}
return LatLngBounds(northeast: LatLng(x1, y1), southwest: LatLng(x0, y0));
}

这段代码对我来说是有用的

你找到方法了吗?是的,它现在对我有用了LatlngBounds Bounds Bounds Fromlatlnglist(列表列表列表){assert(列表.isNotEmpty);double x0,x1,y0,y1;for(列表中的Latlings Latlings){if(x0==null){x0=x1=Latlings.latings;y0=y1=Latlings.longitude;}else{if(latLng.latitude>x1)x1=latLng.latitude;if(latLng.latitude LatLngBounds bound = boundsFromLatLngList(listmap); await Future.delayed(Duration(milliseconds:500)).then((v) async { CameraUpdate u2 = CameraUpdate.newLatLngBounds(bound, 50); this.mapController.animateCamera(u2).then((void v) { check(u2, this.mapController); }); });