简体   繁体   English

调整谷歌地图高度 Flutter

[英]Adjust the height of Google Maps Flutter

How can I adjust the height of a Google Map in order to see the background of the page slightly.如何调整 Google Map 的高度以便稍微看到页面背景。 I've been using curved_navigation_bar It would be great if anybody could help me out, thank you so much in advance..我一直在使用curved_navigation_bar如果有人可以帮助我,那就太好了,非常感谢你提前..

Current result当前结果

在此处输入图像描述

Expected output预期 output

在此处输入图像描述

Navigation Bar导航栏

Widget _content = Container();
Color color = Colors.deepPurple;
class HomePage extends State<MyHomePage>{
  @override
  Widget build(BuildContext context){
    return Scaffold(
      backgroundColor: color,
      body: _content,
      bottomNavigationBar: CurvedNavigationBar(
        backgroundColor: color,
        items: [
          Icon(Icons.home),
          Icon(Icons.dashboard),
          Icon(Icons.settings)
        ],
        onTap: (index){
          setState(() {
            if (index ==0){
              _content = GoogleMapScreen();
            }
            else if (index ==1){
              _content = GoogleMapScreen();
            }
            else{
              _content = GoogleMapScreen();
            }
          });
        },
      ),
    );
  }
}

Google Map Page谷歌 Map 页面

class GoogleMapScreen extends StatefulWidget{
  @override
  _GoogleMapScreenState createState() => _GoogleMapScreenState();
}
class _GoogleMapScreenState extends State<GoogleMapScreen>{
  Set<Marker> _markers = {};
  void _onMapCreated(GoogleMapController controller) {
    setState(() {
      _markers.add(
        Marker(markerId: MarkerId('id-1'),
          position:  LatLng(39.9042, 116.4074),
          infoWindow: InfoWindow(
            title: 'Sample Marker',
            snippet: 'A secret Place',
          )
        ),
      );
    });
  }
  @override
  Widget build(BuildContext context){
    return Scaffold(
        appBar: AppBar(
          title: Text('API MAP'),
        ),
        body: GoogleMap(
            onMapCreated:  _onMapCreated,
            markers: _markers,
            initialCameraPosition: CameraPosition(target: LatLng(39.9042, 116.4074),
              zoom: 15,
            ))

    );
  }
}

You can wrap your GoogleMap widget into a Padding:您可以将 GoogleMap 小部件包装到 Padding 中:

        body:Padding(
            padding: EdgeInsets.only(bottom 16.0),
            child : GoogleMap(
                onMapCreated:  _onMapCreated,
                markers: _markers,
                initialCameraPosition: CameraPosition(target: LatLng(39.9042, 116.4074),
                  zoom: 15,
            )))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM