Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 与谷歌地图和谷歌地点一起畅游_Flutter_Google Maps_Google Places - Fatal编程技术网

Flutter 与谷歌地图和谷歌地点一起畅游

Flutter 与谷歌地图和谷歌地点一起畅游,flutter,google-maps,google-places,Flutter,Google Maps,Google Places,我将谷歌地图和地点与我的颤振应用程序集成,我为谷歌地图创建了一个小部件,并在几个屏幕上使用它 这是我的小部件 import 'package:joobike/utilities/size_confg.dart'; class MapField extends StatefulWidget { final double lat, lng; final List<Marker> markers; MapField({this.lat, this.lng, this.mark

我将谷歌地图和地点与我的颤振应用程序集成,我为谷歌地图创建了一个小部件,并在几个屏幕上使用它

这是我的小部件

import 'package:joobike/utilities/size_confg.dart';

class MapField extends StatefulWidget {
  final double lat, lng;
  final List<Marker> markers;
  MapField({this.lat, this.lng, this.markers});

  @override
  _MapFieldState createState() => _MapFieldState();
}

class _MapFieldState extends State<MapField> {

  @override
  Widget build(BuildContext context) {
    CameraPosition _kGoogleAddress = CameraPosition(
      bearing: 270.0,
      tilt: 30.0,
      target: new LatLng(widget.lat, widget.lng),
      zoom: 14.4746,
    );
    return Container(
      width: double.infinity,
      height: getProportionateScreenHeight(200),
      child: GoogleMap(
        mapToolbarEnabled: true,
        onMapCreated: (GoogleMapController controller) {
          setState(() {
            controller.moveCamera(CameraUpdate.newCameraPosition(CameraPosition(
              bearing: 270,
              target: LatLng(widget.lat, widget.lng),
              tilt: 30.0,
              zoom: 17.0,
            )));
          });
        },
        initialCameraPosition: _kGoogleAddress,
        markers: Set.from(widget.markers),
        mapType: MapType.normal,
      ),
    );
  }
}

你能提供一些你的按钮代码吗?
    try {
      PlacesDetailsResponse detail = await _placesDetailsResponse();
      setState(() {
        lat = detail.result.geometry.location.lat;
        lng = detail.result.geometry.location.lng;
        markers.add(Marker(
            markerId: MarkerId(LatLng(lat, lng).toString()),
            position: LatLng(lat, lng)));
      });
    } catch (error) {
      print(error);
    }
  }```
my problem is when i call this function when i pressed on button the map work good but if i pressed again and choose different place the map still same didn't change so i asked for a way to change the map to the new place when i press on button again