前提・実現したいこと
前提
FlutterでGoogleMapを使いアプリを作成しています。
現状はマーカーの取得を以下のように、Firebaseから取得したデータで表示しています。
dart
GoogleMap( initialCameraPosition: CameraPosition( target: initialPosition, zoom: 14.4746, ), onMapCreated: (mapController) { this.mapController.complete(mapController); }, markers: documents .map((document) => Marker( markerId: MarkerId(document['placeId'] as String), position: LatLng( document['location'].latitude as double, document['location'].longitude as double, ), infoWindow: InfoWindow( title: document['name'] as String?, snippet: document['address'] as String?, ), onTap: () async { print(document['name']); }, )) .toSet(), myLocationEnabled: true,
もとになっているdocumentsは以下のようにStreamで取得しています
final Stream<QuerySnapshot> _storesStream = FirebaseFirestore.instance.collection('stores').snapshots();
それを以下のように別のクラスに渡しています
documents: snapshot.data!.docs,
実現したいこと
別の処理でこのマップに一時的にマーカーを追加したいです。
一時的というのは時間による制限ではなく、オン・オフをboolなどで判定したいです。
発生している問題・エラーメッセージ
Firebaseで直接取得している値をいじって一時的にマーカーを追加することは可能なのでしょうか?
また、それができない場合、なにか代替手段があれば、ご教授願います。
補足情報(FW/ツールのバージョンなど)
Flutter 2.2.3
google_maps_flutter: ^2.0.6
まだ回答がついていません
会員登録して回答してみよう