Skip to content

Commit 901cdbf

Browse files
authored
feat: Renamed all the Layer to StyleLayer. (#139)
- [X] Rename all the `Layer`s to `StyleLayer`s - [X] Rename `AnnotationLayer`s to `Layer`s - [X] Rename `createLayer` method to `createStyleLayer` - [X] Rename `AnnotationManager` to `LayerManager` - [X] Rename `annotation` to `layer` folder - [X] Rename `annotations` pages to `layers` in `example` - [X] Rename `layers` pages to `style_layers` in `example` Closes a task of #113
1 parent f129e86 commit 901cdbf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+464
-465
lines changed

example/integration_test/controller_test.dart

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ void main() {
154154
// ensure no crash if a layer does not exist
155155
await ctrl.removeLayer('notExisting');
156156

157-
const layer = RasterLayer(id: 'rasterLayer', sourceId: 'source');
157+
const layer = RasterStyleLayer(id: 'rasterLayer', sourceId: 'source');
158158
await ctrl.addLayer(layer);
159159
await ctrl.removeLayer(layer.id);
160160
});
@@ -356,7 +356,7 @@ void main() {
356356
final app = App(onMapCreated: ctrlCompleter.complete);
357357
await tester.pumpWidget(app);
358358
final ctrl = await ctrlCompleter.future;
359-
const layer = BackgroundLayer(id: '1', color: Colors.black);
359+
const layer = BackgroundStyleLayer(id: '1', color: Colors.black);
360360
await ctrl.addLayer(layer);
361361
await tester.pumpAndSettle();
362362
});
@@ -365,7 +365,7 @@ void main() {
365365
final app = App(onMapCreated: ctrlCompleter.complete);
366366
await tester.pumpWidget(app);
367367
final ctrl = await ctrlCompleter.future;
368-
const layer = FillLayer(id: '1', sourceId: 'source1');
368+
const layer = FillStyleLayer(id: '1', sourceId: 'source1');
369369
await ctrl.addLayer(layer);
370370
await tester.pumpAndSettle();
371371
});
@@ -374,7 +374,7 @@ void main() {
374374
final app = App(onMapCreated: ctrlCompleter.complete);
375375
await tester.pumpWidget(app);
376376
final ctrl = await ctrlCompleter.future;
377-
const layer = CircleLayer(id: '1', sourceId: 'source1');
377+
const layer = CircleStyleLayer(id: '1', sourceId: 'source1');
378378
await ctrl.addLayer(layer);
379379
await tester.pumpAndSettle();
380380
});
@@ -383,7 +383,7 @@ void main() {
383383
final app = App(onMapCreated: ctrlCompleter.complete);
384384
await tester.pumpWidget(app);
385385
final ctrl = await ctrlCompleter.future;
386-
const layer = FillExtrusionLayer(id: '1', sourceId: 'source1');
386+
const layer = FillExtrusionStyleLayer(id: '1', sourceId: 'source1');
387387
await ctrl.addLayer(layer);
388388
await tester.pumpAndSettle();
389389
});
@@ -392,7 +392,7 @@ void main() {
392392
final app = App(onMapCreated: ctrlCompleter.complete);
393393
await tester.pumpWidget(app);
394394
final ctrl = await ctrlCompleter.future;
395-
const layer = HeatmapLayer(id: '1', sourceId: 'source1');
395+
const layer = HeatmapStyleLayer(id: '1', sourceId: 'source1');
396396
await ctrl.addLayer(layer);
397397
await tester.pumpAndSettle();
398398
});
@@ -401,7 +401,7 @@ void main() {
401401
final app = App(onMapCreated: ctrlCompleter.complete);
402402
await tester.pumpWidget(app);
403403
final ctrl = await ctrlCompleter.future;
404-
const layer = HillshadeLayer(id: '1', sourceId: 'source1');
404+
const layer = HillshadeStyleLayer(id: '1', sourceId: 'source1');
405405
await ctrl.addLayer(layer);
406406
await tester.pumpAndSettle();
407407
});
@@ -410,7 +410,7 @@ void main() {
410410
final app = App(onMapCreated: ctrlCompleter.complete);
411411
await tester.pumpWidget(app);
412412
final ctrl = await ctrlCompleter.future;
413-
const layer = LineLayer(id: '1', sourceId: 'source1');
413+
const layer = LineStyleLayer(id: '1', sourceId: 'source1');
414414
await ctrl.addLayer(layer);
415415
await tester.pumpAndSettle();
416416
});
@@ -419,7 +419,7 @@ void main() {
419419
final app = App(onMapCreated: ctrlCompleter.complete);
420420
await tester.pumpWidget(app);
421421
final ctrl = await ctrlCompleter.future;
422-
const layer = RasterLayer(id: '1', sourceId: 'source1');
422+
const layer = RasterStyleLayer(id: '1', sourceId: 'source1');
423423
await ctrl.addLayer(layer);
424424
await tester.pumpAndSettle();
425425
});
@@ -428,7 +428,7 @@ void main() {
428428
final app = App(onMapCreated: ctrlCompleter.complete);
429429
await tester.pumpWidget(app);
430430
final ctrl = await ctrlCompleter.future;
431-
const layer = SymbolLayer(id: '1', sourceId: 'source1');
431+
const layer = SymbolStyleLayer(id: '1', sourceId: 'source1');
432432
await ctrl.addLayer(layer);
433433
await tester.pumpAndSettle();
434434
});
@@ -437,7 +437,7 @@ void main() {
437437
final app = App(onMapCreated: ctrlCompleter.complete);
438438
await tester.pumpWidget(app);
439439
final ctrl = await ctrlCompleter.future;
440-
const layer = SymbolLayer(id: '1', sourceId: 'source1');
440+
const layer = SymbolStyleLayer(id: '1', sourceId: 'source1');
441441
await ctrl.addLayer(layer);
442442
await tester.pumpAndSettle();
443443
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import 'package:maplibre/maplibre.dart';
22
import 'package:mocktail/mocktail.dart';
33

4-
class MockLayer extends Mock implements Layer {}
4+
class MockStyleLayer extends Mock implements StyleLayer {}

example/lib/animation_page.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class _AnimationPageState extends State<AnimationPage> {
5555
GeoJsonSource(id: _sourceId, data: jsonEncode(geojson.toJson())),
5656
);
5757
await _controller.addLayer(
58-
const LineLayer(
58+
const LineStyleLayer(
5959
id: 'geojson-line',
6060
sourceId: _sourceId,
6161
paint: {'line-color': '#F00', 'line-width': 3},

example/lib/annotations_circle_page.dart

Lines changed: 0 additions & 47 deletions
This file was deleted.
Lines changed: 24 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// ignore_for_file: require_trailing_commas
2-
31
import 'package:flutter/material.dart';
42
import 'package:maplibre/maplibre.dart';
53

@@ -13,87 +11,37 @@ class LayersCirclePage extends StatefulWidget {
1311
State<LayersCirclePage> createState() => _LayersCirclePageState();
1412
}
1513

16-
const _layerId = 'showcaseLayer';
17-
const _sourceId = 'earthquakes';
18-
1914
class _LayersCirclePageState extends State<LayersCirclePage> {
20-
late final MapController _controller;
15+
final _points = <Point>[
16+
Point(coordinates: Position(9.17, 47.68)),
17+
Point(coordinates: Position(9.17, 48)),
18+
Point(coordinates: Position(9, 48)),
19+
Point(coordinates: Position(9.5, 48)),
20+
];
2121

2222
@override
2323
Widget build(BuildContext context) {
2424
return Scaffold(
25-
appBar: AppBar(title: const Text('Circle Layer')),
25+
appBar: AppBar(title: const Text('Circle Layers')),
2626
body: MapLibreMap(
27-
options: MapOptions(
28-
initCenter: Position(-152.9959, 59.8150),
29-
initZoom: 9,
30-
),
31-
onMapCreated: (controller) => _controller = controller,
32-
onStyleLoaded: _onStyleLoaded,
27+
options: MapOptions(initZoom: 7, initCenter: Position(9.17, 47.68)),
28+
onEvent: (event) {
29+
if (event case MapEventClick()) {
30+
setState(() {
31+
_points.add(Point(coordinates: event.point));
32+
});
33+
}
34+
},
35+
layers: [
36+
CircleLayer(
37+
points: _points,
38+
color: Colors.orange.withOpacity(0.5),
39+
radius: 20,
40+
strokeColor: Colors.red,
41+
strokeWidth: 2,
42+
),
43+
],
3344
),
3445
);
3546
}
36-
37-
Future<void> _onStyleLoaded() async {
38-
const earthquakes = GeoJsonSource(
39-
id: _sourceId,
40-
data:
41-
'https://maplibre.org/maplibre-gl-js/docs/assets/earthquakes.geojson',
42-
);
43-
await _controller.addSource(earthquakes);
44-
await _controller.addLayer(_circleLayer);
45-
}
4647
}
47-
48-
const _circleLayer = CircleLayer(
49-
id: _layerId,
50-
sourceId: _sourceId,
51-
paint: {
52-
// Size circle radius by earthquake magnitude and zoom level
53-
'circle-radius': [
54-
'interpolate',
55-
['linear'],
56-
['zoom'],
57-
7,
58-
[
59-
'interpolate',
60-
['linear'],
61-
['get', 'mag'],
62-
1,
63-
1,
64-
6,
65-
50
66-
]
67-
],
68-
// Color circle by earthquake magnitude
69-
'circle-color': [
70-
'interpolate',
71-
['linear'],
72-
['get', 'mag'],
73-
1,
74-
'rgba(33,102,172,0)',
75-
2,
76-
'rgb(103,169,207)',
77-
3,
78-
'rgb(209,229,240)',
79-
4,
80-
'rgb(253,219,199)',
81-
5,
82-
'rgb(239,138,98)',
83-
6,
84-
'rgb(178,24,43)'
85-
],
86-
'circle-stroke-color': 'white',
87-
'circle-stroke-width': 1,
88-
// Transition from heatmap to circle layer by zoom level
89-
'circle-opacity': [
90-
'interpolate',
91-
['linear'],
92-
['zoom'],
93-
7,
94-
0,
95-
8,
96-
1
97-
]
98-
},
99-
);

example/lib/annotations_marker_page.dart renamed to example/lib/layers_marker_page.dart

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import 'package:flutter/material.dart';
22
import 'package:http/http.dart' as http;
33
import 'package:maplibre/maplibre.dart';
4-
import 'package:maplibre_example/layers_symbol_page.dart';
4+
import 'package:maplibre_example/style_layers_symbol_page.dart';
55

66
@immutable
7-
class AnnotationsMarkerPage extends StatefulWidget {
8-
const AnnotationsMarkerPage({super.key});
7+
class LayersMarkerPage extends StatefulWidget {
8+
const LayersMarkerPage({super.key});
99

10-
static const location = '/annotations/marker';
10+
static const location = '/layers/marker';
1111

1212
@override
13-
State<AnnotationsMarkerPage> createState() => _AnnotationsMarkerPageState();
13+
State<LayersMarkerPage> createState() => _LayersMarkerPageState();
1414
}
1515

16-
class _AnnotationsMarkerPageState extends State<AnnotationsMarkerPage> {
16+
class _LayersMarkerPageState extends State<LayersMarkerPage> {
1717
final _points = <Point>[
1818
Point(coordinates: Position(9.17, 47.68)),
1919
Point(coordinates: Position(9.17, 48)),
@@ -27,7 +27,7 @@ class _AnnotationsMarkerPageState extends State<AnnotationsMarkerPage> {
2727
@override
2828
Widget build(BuildContext context) {
2929
return Scaffold(
30-
appBar: AppBar(title: const Text('Marker Annotations')),
30+
appBar: AppBar(title: const Text('Marker Layers')),
3131
body: MapLibreMap(
3232
options: MapOptions(initZoom: 7, initCenter: Position(9.17, 47.68)),
3333
onEvent: (event) async {
@@ -37,7 +37,7 @@ class _AnnotationsMarkerPageState extends State<AnnotationsMarkerPage> {
3737
case MapEventStyleLoaded():
3838
// add marker image to map
3939
final response =
40-
await http.get(Uri.parse(LayersSymbolPage.imageUrl));
40+
await http.get(Uri.parse(StyleLayersSymbolPage.imageUrl));
4141
final bytes = response.bodyBytes;
4242
await _controller.addImage('marker', bytes);
4343
setState(() {
@@ -54,7 +54,7 @@ class _AnnotationsMarkerPageState extends State<AnnotationsMarkerPage> {
5454
}
5555
},
5656
layers: [
57-
MarkerAnnotationLayer(
57+
MarkerLayer(
5858
points: _points,
5959
textField: 'Marker',
6060
textAllowOverlap: true,

example/lib/annotations_mixed_page.dart renamed to example/lib/layers_mixed_page.dart

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ import 'package:flutter/material.dart';
44
import 'package:maplibre/maplibre.dart';
55

66
@immutable
7-
class AnnotationsMixedPage extends StatefulWidget {
8-
const AnnotationsMixedPage({super.key});
7+
class LayersMixedPage extends StatefulWidget {
8+
const LayersMixedPage({super.key});
99

10-
static const location = '/annotations/mixed';
10+
static const location = '/layers/mixed';
1111

1212
@override
13-
State<AnnotationsMixedPage> createState() => _AnnotationsMixedPageState();
13+
State<LayersMixedPage> createState() => _LayersMixedPageState();
1414
}
1515

16-
class _AnnotationsMixedPageState extends State<AnnotationsMixedPage> {
16+
class _LayersMixedPageState extends State<LayersMixedPage> {
1717
final _random = Random.secure();
1818
final _circlePoints = <Point>[
1919
Point(coordinates: Position(9.17, 47.68)),
@@ -22,12 +22,12 @@ class _AnnotationsMixedPageState extends State<AnnotationsMixedPage> {
2222
Point(coordinates: Position(9.5, 48)),
2323
];
2424
Color _circleColor = Colors.orange.withOpacity(0.5);
25-
PolylineAnnotationLayer? _polylineLayer;
25+
PolylineLayer? _polylineLayer;
2626

2727
@override
2828
Widget build(BuildContext context) {
2929
return Scaffold(
30-
appBar: AppBar(title: const Text('Mixed Annotations')),
30+
appBar: AppBar(title: const Text('Mixed Layers')),
3131
body: Column(
3232
children: [
3333
Padding(
@@ -53,7 +53,7 @@ class _AnnotationsMixedPageState extends State<AnnotationsMixedPage> {
5353
onPressed: () {
5454
setState(() {
5555
if (_polylineLayer == null) {
56-
_polylineLayer = PolylineAnnotationLayer(
56+
_polylineLayer = PolylineLayer(
5757
polylines: [
5858
LineString(
5959
coordinates: [
@@ -89,14 +89,14 @@ class _AnnotationsMixedPageState extends State<AnnotationsMixedPage> {
8989
}
9090
},
9191
layers: [
92-
CircleAnnotationLayer(
92+
CircleLayer(
9393
points: _circlePoints,
9494
color: _circleColor,
9595
radius: 20,
9696
strokeColor: Colors.red,
9797
strokeWidth: 2,
9898
),
99-
if (_polylineLayer case final AnnotationLayer layer) layer,
99+
if (_polylineLayer case final Layer layer) layer,
100100
],
101101
),
102102
),

0 commit comments

Comments
 (0)