Skip to content

Commit 736761d

Browse files
[google_maps_flutter] Add CameraUpdate.newLatLngBoundsWithEdgeInsets on Web (#183439)
1 parent 26ec483 commit 736761d

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## 0.6.3
22

3-
* Throws `UnsupportedError` for `CameraUpdate.newLatLngBoundsWithEdgeInsets` (not supported on web).
3+
* Adds support for `CameraUpdate.newLatLngBoundsWithEdgeInsets` using native `fitBounds` padding.
44

55
## 0.6.2
66

packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,9 +1021,20 @@ void _applyCameraUpdate(gmaps.Map map, CameraUpdate update) {
10211021
case 'zoomTo':
10221022
map.zoom = json[1]! as num;
10231023
case 'newLatLngBoundsWithEdgeInsets':
1024-
throw UnsupportedError(
1025-
'CameraUpdate.newLatLngBoundsWithEdgeInsets is not supported on web. '
1026-
'Use CameraUpdate.newLatLngBounds with uniform padding instead.',
1024+
final List<Object?> latLngPair = asJsonList(json[1]);
1025+
final List<Object?> latLng1 = asJsonList(latLngPair[0]);
1026+
final List<Object?> latLng2 = asJsonList(latLngPair[1]);
1027+
map.fitBounds(
1028+
gmaps.LatLngBounds(
1029+
gmaps.LatLng(latLng1[0]! as num, latLng1[1]! as num),
1030+
gmaps.LatLng(latLng2[0]! as num, latLng2[1]! as num),
1031+
),
1032+
gmaps.Padding(
1033+
top: json[2]! as num,
1034+
left: json[3]! as num,
1035+
bottom: json[4]! as num,
1036+
right: json[5]! as num,
1037+
),
10271038
);
10281039
default:
10291040
throw UnimplementedError('Unimplemented CameraMove: ${json[0]}.');

0 commit comments

Comments
 (0)