如何设置谷歌地图的大小不重叠BottomNavigationBar

时间:2018-07-05 03:23:46

标签: google-maps flutter bottomnavigationview

我有以下代码来设置地图叠加层的大小。请注意,宽度是根据MediaQuery设置的。高度也是这样设置的,但是它总是与底部导航栏重叠

void buildMap() async {
if (mapOverlayController != null) return;

var mq = MediaQuery.of(context);
// add delay so overlay is positioned correctly
await new Future<Null>.delayed(new Duration(milliseconds: 20));

mapOverlayController = GoogleMapOverlayController.fromSize(
  width: mq.size.width,
  height: 300.0,
  options: GoogleMapOptions(
    trackCameraPosition: true,
  ),
);
mapOverlayController.mapController.addListener(_onMapChanged);
mapOverlayController.overlayController.activateOverlay();
setState(() {});
 }

 Widget renderMap() {
if (mapOverlayController == null) {
  return Center(
      child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            SizedBox(
              height: 150.0,
              width: 150.0,
              child: new CircularProgressIndicator(
                valueColor: AlwaysStoppedAnimation<Color>(Colors.redAccent),
                value: null,
                strokeWidth: 7.0,
              ),
            ),
            new Container(
              margin: const EdgeInsets.only(top: 25.0),
              child: new Center(
                child: new Text(
                  "Loading.. please wait...",
                ),
              ),
            ),
          ]));
} else {
  return GoogleMapOverlay(controller: mapOverlayController);
}
}

我希望地图的高度包括地图栏下方和底部导航栏上方的所有区域

I would like the height of the map to include all of the area below the map bar and above the bottom navigation bar

1 个答案:

答案 0 :(得分:0)

不幸的是,那些Google Map软件包没有集成在flutter的小部件树中,只是作为本机视图挂在flutter视图的顶部。

根据您的用例,如果您只需要地图的图像(带有标记或区域),则可以使用Google static maps api,调用其HTTP端点并获取图像。

如果您确实需要可调整的地图,则需要根据需要修改本机代码本身。

相关问题