@@ -12,7 +12,6 @@ import 'package:ensemble/layout/templated.dart';
12
12
import 'package:ensemble/screen_controller.dart' ;
13
13
import 'package:ensemble/util/debouncer.dart' ;
14
14
import 'package:ensemble/util/utils.dart' ;
15
- import 'package:ensemble/widget/shape.dart' ;
16
15
import 'package:ensemble_location/location_manager.dart' ;
17
16
import 'package:ensemble_location/widget/maps/custom_marker_pin.dart' ;
18
17
import 'package:ensemble_location/widget/maps/map_actions.dart' ;
@@ -41,6 +40,8 @@ class EnsembleMapState extends MapsActionableState
41
40
static const MAX_WIDTH = 500 ;
42
41
static const MAX_HEIGHT = 500 ;
43
42
43
+ late FixedMarker _fixedMarker;
44
+
44
45
final Completer <GoogleMapController > _controller =
45
46
Completer <GoogleMapController >();
46
47
@@ -85,6 +86,7 @@ class EnsembleMapState extends MapsActionableState
85
86
@override
86
87
void initState () {
87
88
super .initState ();
89
+ _fixedMarker = FixedMarker (position: widget.controller.defaultCameraLatLng);
88
90
_initCurrentLocation ();
89
91
}
90
92
@@ -230,6 +232,12 @@ class EnsembleMapState extends MapsActionableState
230
232
_selectedMarkerId = markerId;
231
233
}
232
234
235
+ // build marker image for fixed marker
236
+ if (markerTemplate != null && widget.controller.fixedMarker) {
237
+ _fixedMarker.icon =
238
+ await _buildMarkerFromTemplate (payloads.first, markerTemplate);
239
+ }
240
+
233
241
BitmapDescriptor ? markerAsset;
234
242
double zIndex = 0 ;
235
243
if (markerId == _selectedMarkerId) {
@@ -255,6 +263,10 @@ class EnsembleMapState extends MapsActionableState
255
263
position: markerPayload.latLng,
256
264
icon: markerAsset ?? BitmapDescriptor .defaultMarker,
257
265
consumeTapEvents: true ,
266
+ draggable: widget.controller.draggableMarker,
267
+ onDrag: (latLng) {
268
+ _moveCamera (latLng);
269
+ },
258
270
onTap: () {
259
271
_selectMarker (markerId);
260
272
@@ -571,6 +583,13 @@ class EnsembleMapState extends MapsActionableState
571
583
//log("Camera moved");
572
584
});
573
585
}
586
+
587
+ if (widget.controller.fixedMarker &&
588
+ _fixedMarker.position != position.target) {
589
+ setState (() {
590
+ _fixedMarker.position = position.target;
591
+ });
592
+ }
574
593
}
575
594
576
595
void _onCameraIdle () {}
@@ -597,7 +616,17 @@ class EnsembleMapState extends MapsActionableState
597
616
Set <Marker > _getMarkers () {
598
617
Set <Marker > markers = {};
599
618
for (MarkerPayload markerPayload in _markerPayloads) {
600
- if (markerPayload.marker != null ) {
619
+ if (widget.controller.fixedMarker) {
620
+ markers.add (Marker (
621
+ markerId: const MarkerId ("fixed_marker" ),
622
+ position: _fixedMarker.position,
623
+ icon: _fixedMarker.icon ?? BitmapDescriptor .defaultMarker,
624
+ draggable: widget.controller.draggableMarker,
625
+ onDrag: (position) {
626
+ _moveCamera (position);
627
+ },
628
+ ));
629
+ } else if (markerPayload.marker != null ) {
601
630
markers.add (markerPayload.marker! );
602
631
}
603
632
}
@@ -625,3 +654,10 @@ class MarkerPayload {
625
654
final LatLng latLng;
626
655
Marker ? marker;
627
656
}
657
+
658
+ class FixedMarker {
659
+ LatLng position;
660
+ BitmapDescriptor ? icon;
661
+
662
+ FixedMarker ({required this .position, this .icon});
663
+ }
0 commit comments