Skip to content

Commit d570358

Browse files
Release 0.24.0 (#647)
Co-authored-by: andynewman10 <[email protected]>
1 parent 4acb180 commit d570358

File tree

16 files changed

+348
-159
lines changed

16 files changed

+348
-159
lines changed

CHANGELOG.md

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,49 @@
1-
# Change Log
1+
# CHANGELOG
22

33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [0.24.0](https://github.com/maplibre/flutter-maplibre-gl/compare/v0.23.0...v0.24.0)
7+
> **Note**: This release has breaking changes.\
8+
> We apologize for the quick change in 0.24.0: this version definitively stabilizes the signatures of feature interaction callbacks.
9+
10+
This release restores the **feature id** and makes the `Annotation` parameter **nullable** for all feature interaction callbacks (`tap` / `drag` / `hover`).\
11+
This unblocks interaction with style-layer features not managed by annotation managers (i.e. added via `addLayer*` / style APIs).
12+
13+
### Breaking Changes
14+
* **Tap**: `OnFeatureInteractionCallback``(Point<double> point, LatLng coordinates, String id, String layerId, Annotation? annotation)`.
15+
16+
* **Drag**: `OnFeatureDragCallback``(Point<double> point, LatLng origin, LatLng current, LatLng delta, String id, Annotation? annotation, DragEventType eventType)`.
17+
18+
* **Hover**: `OnFeatureHoverCallback``Point<double> point, LatLng coordinates, String id, Annotation? annotation, HoverEventType eventType)`.
19+
20+
* **Update existing listeners**: The short‑lived 0.23.0-only signatures (without `id`) are removed.
21+
* For unmanaged style layer features `annotation` is `null` (`unmanaged` means sources/layers you add via style APIs like `addGeoJsonSource` + `addSymbolLayer`).
22+
* For managed annotations it is the `Annotation` object.
23+
24+
### Reasoning
25+
In 0.23.0 the move to annotation objects inadvertently dropped interaction for unmanaged style features. Reintroducing `id` (and making `annotation` nullable) normalizes all three interaction paths without creating phantom annotation wrappers.
26+
27+
### Migration Example
28+
Before (0.23.0):
29+
```
30+
controller.onFeatureTapped.add((p, latLng, annotation, layerId) {
31+
print(annotation.id);
32+
});
33+
```
34+
After (>=0.24.0):
35+
```
36+
controller.onFeatureTapped.add((p, latLng, id, layerId, annotation) {
37+
print('feature id=$id managed=${annotation != null}');
38+
});
39+
```
40+
41+
### Refactor / Quality
42+
* (web) Refactored `onMapClick` (degenerate bbox + interactive layer filter) to surface features inserted via style APIs (unmanaged style-layer features) in `onFeatureTapped` (previously skipped; returned now with `id`, `layerId` and `annotation = null`) (#646).
43+
* (web) Ensure map container stretches vertically by adding `style.height = '100%'` to the registered div (prevents occasional zero-height layout issues in flexible parents) (#641)
44+
45+
**Full Changelog**: [v0.23.0...v0.24.0](https://github.com/maplibre/flutter-maplibre-gl/compare/v0.23.0...v0.24.0)
46+
647
## [0.23.0](https://github.com/maplibre/flutter-maplibre-gl/compare/v0.22.0...v0.23.0)
748
> **Note**: This release has breaking changes.
849

maplibre_gl/CHANGELOG.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,44 @@
1+
## [0.24.0](https://github.com/maplibre/flutter-maplibre-gl/compare/v0.23.0...v0.24.0)
2+
> **Note**: This release has breaking changes.\
3+
> We apologize for the quick change in 0.24.0: this version definitively stabilizes the signatures of feature interaction callbacks.
4+
5+
This release restores the **feature id** and makes the `Annotation` parameter **nullable** for all feature interaction callbacks (`tap` / `drag` / `hover`).\
6+
This unblocks interaction with style-layer features not managed by annotation managers (i.e. added via `addLayer*` / style APIs).
7+
8+
### Breaking Changes
9+
* **Tap**: `OnFeatureInteractionCallback``(Point<double> point, LatLng coordinates, String id, String layerId, Annotation? annotation)`.
10+
11+
* **Drag**: `OnFeatureDragCallback``(Point<double> point, LatLng origin, LatLng current, LatLng delta, String id, Annotation? annotation, DragEventType eventType)`.
12+
13+
* **Hover**: `OnFeatureHoverCallback``Point<double> point, LatLng coordinates, String id, Annotation? annotation, HoverEventType eventType)`.
14+
15+
* **Update existing listeners**: The short‑lived 0.23.0-only signatures (without `id`) are removed.
16+
* For unmanaged style layer features `annotation` is `null` (`unmanaged` means sources/layers you add via style APIs like `addGeoJsonSource` + `addSymbolLayer`).
17+
* For managed annotations it is the `Annotation` object.
18+
19+
### Reasoning
20+
In 0.23.0 the move to annotation objects inadvertently dropped interaction for unmanaged style features. Reintroducing `id` (and making `annotation` nullable) normalizes all three interaction paths without creating phantom annotation wrappers.
21+
22+
### Migration Example
23+
Before (0.23.0):
24+
```
25+
controller.onFeatureTapped.add((p, latLng, annotation, layerId) {
26+
print(annotation.id);
27+
});
28+
```
29+
After (>=0.24.0):
30+
```
31+
controller.onFeatureTapped.add((p, latLng, id, layerId, annotation) {
32+
print('feature id=$id managed=${annotation != null}');
33+
});
34+
```
35+
36+
### Refactor / Quality
37+
* (web) Refactored `onMapClick` (degenerate bbox + interactive layer filter) to surface features inserted via style APIs (unmanaged style-layer features) in `onFeatureTapped` (previously skipped; returned now with `id`, `layerId` and `annotation = null`) (#646).
38+
* (web) Ensure map container stretches vertically by adding `style.height = '100%'` to the registered div (prevents occasional zero-height layout issues in flexible parents) (#641)
39+
40+
**Full Changelog**: [v0.23.0...v0.24.0](https://github.com/maplibre/flutter-maplibre-gl/compare/v0.23.0...v0.24.0)
41+
142
## [0.23.0](https://github.com/maplibre/flutter-maplibre-gl/compare/v0.22.0...v0.23.0)
243
> **Note**: This release has breaking changes.
344

maplibre_gl/ios/maplibre_gl.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
Pod::Spec.new do |s|
55
s.name = 'maplibre_gl'
6-
s.version = '0.23.0'
6+
s.version = '0.24.0'
77
s.summary = 'MapLibre GL Flutter plugin'
88
s.description = <<-DESC
99
MapLibre GL Flutter plugin.

maplibre_gl/lib/src/annotation_manager.dart

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ abstract class AnnotationManager<T extends Annotation> {
146146
LatLng origin,
147147
LatLng current,
148148
LatLng delta,
149-
Annotation annotation,
149+
String id,
150+
Annotation? annotation,
150151
DragEventType eventType,
151152
) async {
152153
if (annotation is T) {
@@ -157,18 +158,18 @@ abstract class AnnotationManager<T extends Annotation> {
157158

158159
/// Updates (re-sets) an existing annotation quickly by only replacing its
159160
/// underlying GeoJSON feature if it remains on the same logical layer.
160-
Future<void> set(T anntotation) async {
161-
assert(_idToAnnotation.containsKey(anntotation.id),
161+
Future<void> set(T annotation) async {
162+
assert(_idToAnnotation.containsKey(annotation.id),
162163
"you can only set existing annotations");
163-
_idToAnnotation[anntotation.id] = anntotation;
164-
final oldLayerIndex = _idToLayerIndex[anntotation.id];
165-
final layerIndex = selectLayer != null ? selectLayer!(anntotation) : 0;
164+
_idToAnnotation[annotation.id] = annotation;
165+
final oldLayerIndex = _idToLayerIndex[annotation.id];
166+
final layerIndex = selectLayer != null ? selectLayer!(annotation) : 0;
166167
if (oldLayerIndex != layerIndex) {
167168
// Layer changed; must rewrite all sources.
168169
await _setAll();
169170
} else {
170171
await controller.setGeoJsonFeature(
171-
_makeLayerId(layerIndex), anntotation.toGeoJson());
172+
_makeLayerId(layerIndex), annotation.toGeoJson());
172173
}
173174
}
174175
}

maplibre_gl/lib/src/controller.dart

Lines changed: 66 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,34 @@ part of '../maplibre_gl.dart';
77
typedef OnMapClickCallback = void Function(
88
Point<double> point, LatLng coordinates);
99

10-
typedef OnFeatureInteractionCallback = void Function(Point<double> point,
11-
LatLng coordinates, Annotation annotation, String layerId);
10+
// New generalized feature interaction callback that always provides a raw feature id.
11+
// If the feature also corresponds to a managed annotation, the annotation parameter
12+
// is non-null; otherwise it is null (e.g. raw style layer feature not managed by an AnnotationManager).
13+
typedef OnFeatureInteractionCallback = void Function(
14+
Point<double> point,
15+
LatLng coordinates,
16+
String id,
17+
String layerId,
18+
Annotation? annotation,
19+
);
1220

1321
typedef OnFeatureDragCallback = void Function(
1422
Point<double> point,
1523
LatLng origin,
1624
LatLng current,
1725
LatLng delta,
18-
Annotation annotation,
26+
String id,
27+
Annotation? annotation,
1928
DragEventType eventType,
2029
);
2130

22-
typedef OnFeatureHoverCallback = void Function(Point<double> point,
23-
LatLng latLng, Annotation annotation, HoverEventType eventType);
31+
typedef OnFeatureHoverCallback = void Function(
32+
Point<double> point,
33+
LatLng coordinates,
34+
String id,
35+
Annotation? annotation,
36+
HoverEventType eventType,
37+
);
2438

2539
typedef OnMapLongClickCallback = void Function(
2640
Point<double> point, LatLng coordinates);
@@ -95,19 +109,19 @@ class MapLibreMapController extends ChangeNotifier {
95109
_cameraPosition = initialCameraPosition;
96110

97111
_maplibrePlatform.onFeatureTappedPlatform.add((payload) {
98-
final id = payload["id"];
112+
final id = payload["id"].toString();
113+
final layerId = payload["layerId"];
114+
final point = payload["point"];
115+
final latLng = payload["latLng"];
99116
final annotation = getAnnotationById(id);
100-
if (annotation == null) return;
101-
// Call onFeatureTapped callbacks
117+
118+
// Call all generic feature tapped callbacks
102119
for (final fun in List.of(onFeatureTapped)) {
103-
fun(
104-
payload["point"],
105-
payload["latLng"],
106-
annotation,
107-
payload["layerId"],
108-
);
120+
// New signature supplies id and (possibly null) annotation
121+
fun(point, latLng, id, layerId, annotation);
109122
}
110-
// Call specific annotation callbacks (onSymbolTapped, onLineTapped...)
123+
124+
// If we have a managed annotation, call specific annotation callbacks (onSymbolTapped, onLineTapped...)
111125
ArgumentCallbacks? annotationTappedCallbacks;
112126
if (annotation is Line) {
113127
annotationTappedCallbacks = onLineTapped;
@@ -119,33 +133,53 @@ class MapLibreMapController extends ChangeNotifier {
119133
annotationTappedCallbacks = onCircleTapped;
120134
}
121135
annotationTappedCallbacks?.call(annotation);
136+
137+
if (annotation != null) {
138+
ArgumentCallbacks? annotationTappedCallbacks;
139+
if (annotation is Line) {
140+
annotationTappedCallbacks = onLineTapped;
141+
} else if (annotation is Symbol) {
142+
annotationTappedCallbacks = onSymbolTapped;
143+
} else if (annotation is Fill) {
144+
annotationTappedCallbacks = onFillTapped;
145+
} else if (annotation is Circle) {
146+
annotationTappedCallbacks = onCircleTapped;
147+
}
148+
annotationTappedCallbacks?.call(annotation);
149+
}
122150
});
123151

124152
_maplibrePlatform.onFeatureDraggedPlatform.add((payload) {
153+
final id = payload["id"];
154+
final annotation = getAnnotationById(id);
155+
final enmDragEventType = DragEventType.values
156+
.firstWhere((element) => element.name == payload["eventType"]);
125157
for (final fun in List.of(onFeatureDrag)) {
126-
final enmDragEventType = DragEventType.values
127-
.firstWhere((element) => element.name == payload["eventType"]);
128-
final id = payload["id"];
129-
final annotation = getAnnotationById(id);
130-
if (annotation == null) return;
131158
fun(
132159
payload["point"],
133160
payload["origin"],
134161
payload["current"],
135162
payload["delta"],
163+
id,
136164
annotation,
137165
enmDragEventType,
138166
);
139167
}
140168
});
141169

142170
_maplibrePlatform.onFeatureHoverPlatform.add((payload) {
143-
final annotation = getAnnotationById(payload["id"]);
144-
if (annotation == null) return;
171+
final id = payload["id"];
172+
final annotation = getAnnotationById(id);
145173
final hoverEventType = HoverEventType.values
146174
.firstWhere((e) => e.name == payload["eventType"]);
147175
for (final fun in List.of(onFeatureHover)) {
148-
fun(payload["point"], payload["latLng"], annotation, hoverEventType);
176+
fun(
177+
payload["point"],
178+
payload["latLng"],
179+
id,
180+
annotation,
181+
hoverEventType,
182+
);
149183
}
150184
});
151185

@@ -222,12 +256,15 @@ class MapLibreMapController extends ChangeNotifier {
222256
});
223257
}
224258

225-
Annotation? getAnnotationById(dynamic id) => id == null
226-
? null
227-
: fillManager?.byId(id) ??
228-
lineManager?.byId(id) ??
229-
symbolManager?.byId(id) ??
230-
circleManager?.byId(id);
259+
Annotation? getAnnotationById(dynamic id) {
260+
if (id == null) return null;
261+
262+
final formattedId = id.toString();
263+
return fillManager?.byId(formattedId) ??
264+
lineManager?.byId(formattedId) ??
265+
symbolManager?.byId(formattedId) ??
266+
circleManager?.byId(formattedId);
267+
}
231268

232269
FillManager? fillManager;
233270
LineManager? lineManager;

maplibre_gl/pubspec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: maplibre_gl
22
description: A Flutter plugin for integrating MapLibre Maps inside a Flutter application on Android, iOS and web platforms.
3-
version: 0.23.0
3+
version: 0.24.0
44
repository: https://github.com/maplibre/flutter-maplibre-gl
55
issue_tracker: https://github.com/maplibre/flutter-maplibre-gl/issues
66
resolution: workspace
@@ -12,8 +12,8 @@ environment:
1212
dependencies:
1313
flutter:
1414
sdk: flutter
15-
maplibre_gl_platform_interface: ^0.23.0
16-
maplibre_gl_web: ^0.23.0
15+
maplibre_gl_platform_interface: ^0.24.0
16+
maplibre_gl_web: ^0.24.0
1717

1818
dev_dependencies:
1919
very_good_analysis: ^10.0.0

0 commit comments

Comments
 (0)