Skip to content

Commit acc1e0e

Browse files
committed
Fix
1 parent d030435 commit acc1e0e

File tree

1 file changed

+22
-43
lines changed

1 file changed

+22
-43
lines changed

example/lib/layer.dart

Lines changed: 22 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ class LayerState extends State {
4747
dragEnabled: false,
4848
myLocationEnabled: true,
4949
onMapCreated: _onMapCreated,
50-
onMapClick: (point, latLong) =>
51-
debugPrint(point.toString() + latLong.toString()),
50+
onMapClick: (point, latLong) => debugPrint(point.toString() + latLong.toString()),
5251
onStyleLoadedCallback: _onStyleLoadedCallback,
5352
initialCameraPosition: const CameraPosition(
5453
target: center,
@@ -61,9 +60,7 @@ class LayerState extends State {
6160
onPressed: () {
6261
controller
6362
.setLayerProperties(
64-
"lines",
65-
LineLayerProperties.fromJson(
66-
{"visibility": linesVisible ? "none" : "visible"}))
63+
"lines", LineLayerProperties.fromJson({"visibility": linesVisible ? "none" : "visible"}))
6764
.then((value) => setState(() => linesVisible = !linesVisible));
6865
},
6966
child: const Text('toggle line visibility'),
@@ -72,9 +69,7 @@ class LayerState extends State {
7269
onPressed: () {
7370
controller
7471
.setLayerProperties(
75-
"lines",
76-
LineLayerProperties.fromJson(
77-
{"line-color": linesRed ? "#0000ff" : "#ff0000"}))
72+
"lines", LineLayerProperties.fromJson({"line-color": linesRed ? "#0000ff" : "#ff0000"}))
7873
.then((value) => setState(() => linesRed = !linesRed));
7974
},
8075
child: const Text('toggle line color'),
@@ -83,9 +78,7 @@ class LayerState extends State {
8378
onPressed: () {
8479
controller
8580
.setLayerProperties(
86-
"fills",
87-
FillLayerProperties.fromJson(
88-
{"visibility": fillsVisible ? "none" : "visible"}))
81+
"fills", FillLayerProperties.fromJson({"visibility": fillsVisible ? "none" : "visible"}))
8982
.then((value) => setState(() => fillsVisible = !fillsVisible));
9083
},
9184
child: const Text('toggle fill visibility'),
@@ -94,9 +87,7 @@ class LayerState extends State {
9487
onPressed: () {
9588
controller
9689
.setLayerProperties(
97-
"fills",
98-
FillLayerProperties.fromJson(
99-
{"fill-color": fillsRed ? "#0000ff" : "#ff0000"}))
90+
"fills", FillLayerProperties.fromJson({"fill-color": fillsRed ? "#0000ff" : "#ff0000"}))
10091
.then((value) => setState(() => fillsRed = !fillsRed));
10192
},
10293
child: const Text('toggle fill color'),
@@ -105,21 +96,16 @@ class LayerState extends State {
10596
onPressed: () {
10697
controller
10798
.setLayerProperties(
108-
"circles",
109-
CircleLayerProperties.fromJson(
110-
{"visibility": circlesVisible ? "none" : "visible"}))
111-
.then(
112-
(value) => setState(() => circlesVisible = !circlesVisible));
99+
"circles", CircleLayerProperties.fromJson({"visibility": circlesVisible ? "none" : "visible"}))
100+
.then((value) => setState(() => circlesVisible = !circlesVisible));
113101
},
114102
child: const Text('toggle circle visibility'),
115103
),
116104
TextButton(
117105
onPressed: () {
118106
controller
119107
.setLayerProperties(
120-
"circles",
121-
CircleLayerProperties.fromJson(
122-
{"circle-color": circlesRed ? "#0000ff" : "#ff0000"}))
108+
"circles", CircleLayerProperties.fromJson({"circle-color": circlesRed ? "#0000ff" : "#ff0000"}))
123109
.then((value) => setState(() => circlesRed = !circlesRed));
124110
},
125111
child: const Text('toggle circle color'),
@@ -128,11 +114,8 @@ class LayerState extends State {
128114
onPressed: () {
129115
controller
130116
.setLayerProperties(
131-
"symbols",
132-
SymbolLayerProperties.fromJson(
133-
{"visibility": symbolsVisible ? "none" : "visible"}))
134-
.then(
135-
(value) => setState(() => symbolsVisible = !symbolsVisible));
117+
"symbols", SymbolLayerProperties.fromJson({"visibility": symbolsVisible ? "none" : "visible"}))
118+
.then((value) => setState(() => symbolsVisible = !symbolsVisible));
136119
},
137120
child: const Text('toggle (non-moving) symbols visibility'),
138121
),
@@ -142,11 +125,10 @@ class LayerState extends State {
142125
void _onMapCreated(MapLibreMapController controller) {
143126
this.controller = controller;
144127

145-
controller.onFeatureTapped.add(onFeatureTap);
128+
controller.onFeatureTapped.add(onFeatureTap as OnFeatureInteractionCallback);
146129
}
147130

148-
void onFeatureTap(
149-
dynamic featureId, Point<double> point, LatLng latLng, String layerId) {
131+
void onFeatureTap(dynamic featureId, Point<double> point, LatLng latLng, String layerId) {
150132
final snackBar = SnackBar(
151133
content: Text(
152134
'Tapped feature with id $featureId on layer $layerId',
@@ -159,8 +141,7 @@ class LayerState extends State {
159141
}
160142

161143
Future<void> _onStyleLoadedCallback() async {
162-
await addImageFromAsset(
163-
controller, "custom-marker", "assets/symbols/custom-marker.png");
144+
await addImageFromAsset(controller, "custom-marker", "assets/symbols/custom-marker.png");
164145
await controller.addGeoJsonSource("points", _points);
165146
await controller.addGeoJsonSource("moving", _movingFeature(0));
166147

@@ -204,17 +185,15 @@ class LayerState extends State {
204185
await controller.addLineLayer(
205186
"fills",
206187
"lines",
207-
LineLayerProperties(
208-
lineColor: Colors.lightBlue.toHexStringRGB(),
209-
lineWidth: [
210-
Expressions.interpolate,
211-
["linear"],
212-
[Expressions.zoom],
213-
11.0,
214-
2.0,
215-
20.0,
216-
10.0
217-
]),
188+
LineLayerProperties(lineColor: Colors.lightBlue.toHexStringRGB(), lineWidth: [
189+
Expressions.interpolate,
190+
["linear"],
191+
[Expressions.zoom],
192+
11.0,
193+
2.0,
194+
20.0,
195+
10.0
196+
]),
218197
);
219198

220199
await controller.addCircleLayer(

0 commit comments

Comments
 (0)