Skip to content

Commit b6324e8

Browse files
authored
fix: allowInteraction on web (#366)
1 parent 3e6c428 commit b6324e8

File tree

3 files changed

+11
-28
lines changed

3 files changed

+11
-28
lines changed

example/lib/widget_layer_page.dart

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,43 +28,27 @@ class _WidgetLayerPageState extends State<WidgetLayerPage> {
2828
Marker(
2929
size: Size.square(50),
3030
point: Geographic(lon: -10, lat: 0),
31-
child: Icon(
32-
Icons.location_on,
33-
color: Colors.red,
34-
size: 50,
35-
),
31+
child: Icon(Icons.location_on, color: Colors.red, size: 50),
3632
alignment: Alignment.bottomCenter,
3733
),
3834
Marker(
3935
size: Size.square(50),
4036
point: Geographic(lon: -5, lat: 0),
41-
child: Icon(
42-
Icons.location_on,
43-
color: Colors.red,
44-
size: 50,
45-
),
37+
child: Icon(Icons.location_on, color: Colors.red, size: 50),
4638
alignment: Alignment.bottomCenter,
4739
rotate: true,
4840
),
4941
Marker(
5042
size: Size.square(50),
5143
point: Geographic(lon: 0, lat: 0),
52-
child: Icon(
53-
Icons.location_on,
54-
color: Colors.red,
55-
size: 50,
56-
),
44+
child: Icon(Icons.location_on, color: Colors.red, size: 50),
5745
alignment: Alignment.bottomCenter,
5846
flat: true,
5947
),
6048
Marker(
6149
size: Size.square(50),
6250
point: Geographic(lon: 5, lat: 0),
63-
child: Icon(
64-
Icons.location_on,
65-
color: Colors.red,
66-
size: 50,
67-
),
51+
child: Icon(Icons.location_on, color: Colors.red, size: 50),
6852
alignment: Alignment.bottomCenter,
6953
flat: true,
7054
rotate: true,

lib/src/widget_layer.dart

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ class WidgetLayer extends StatelessWidget {
1919
/// The list of [Marker]s.
2020
final List<Marker> markers;
2121

22-
/// Allow gestures on [Marker]s.
22+
/// Allow gestures on [Marker]s on iOS and Android. The flag is not a
23+
/// requirement on web but it mimics the same behaviour from other platforms
24+
/// when set.
2325
final bool allowInteraction;
2426

2527
@override
@@ -45,7 +47,9 @@ class WidgetLayer extends StatelessWidget {
4547
child: Transform(
4648
transform: matrix,
4749
alignment: m.alignment,
48-
child: m.child,
50+
child: (allowInteraction && kIsWeb)
51+
? PointerInterceptor(child: m.child)
52+
: m.child,
4953
),
5054
);
5155
})
@@ -56,11 +60,6 @@ class WidgetLayer extends StatelessWidget {
5660
final offsets = controller.toScreenLocations(points);
5761

5862
if (allowInteraction) {
59-
if (kIsWeb) {
60-
// Web requires a PointerInterceptor to prevent the HtmlElementView from
61-
// receiving gestures.
62-
return PointerInterceptor(child: buildChild(offsets));
63-
}
6463
return buildChild(offsets);
6564
} else {
6665
// Android and iOS needs a TranslucentPointer so that the widgets don't prevent

maplibre_ios/ios/maplibre_ios/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ let package = Package(
2828
],
2929
cSettings: [
3030
.headerSearchPath("include/maplibre_ios"),
31-
],
31+
]
3232
),
3333
// FOR LOCAL LIBRARY
3434
// .binaryTarget(

0 commit comments

Comments
 (0)