【发布时间】:2020-12-09 19:07:42
【问题描述】:
我正在创建两种标记类型。一个来自 Bloc 并通过消费者,另一个来自我的主要班级。如何设置标记:同时接受 Provmap.markers 和 Set.of(markers.values)?谷歌地图代码如下:
body: Stack(children: <Widget>[
SizedBox(
width: MediaQuery.of(context)
.size
.width, // or use fixed size like 200
height: MediaQuery.of(context).size.height,
child:
Consumer<ProviderMaps>(builder: (context, Provmap, widget) {
return GoogleMap(
myLocationEnabled: true,
compassEnabled: true,
mapToolbarEnabled: true,
zoomControlsEnabled: true,
zoomGesturesEnabled: true,
onCameraMove: _onCameraMove,
onLongPress: _addMarkerLongPressed,
myLocationButtonEnabled: false,
mapType: maptype,
onTap: Provmap.addMarker,
// markers: Provmap.markers, ///cant pass both...
markers: Set<Marker>.of(markers.values),
circles: Set<Circle>.of(circles.values),
polylines: Provmap.polyline,
polygons: Provmap.polygon,
initialCameraPosition:
CameraPosition(target: LatLng(lat, lng), zoom: 10.0),
onMapCreated: (GoogleMapController controller) {
mapController = controller;
_controller.complete(controller);
isMapCreated = true;
changeMapMode();
changeMapType();
setState(() {});
Provmap.onCreated;
});
})),
【问题讨论】: