What is the bug?
In line with #1347 and #1295, there are more issues with bounds for polar CRS.
In some cases fitBounds (and my copy flyToBounds) throws an error:
══╡ EXCEPTION CAUGHT BY GESTURE ╞═══════════════════════════════════════════════════════════════════
The following RangeError was thrown while handling a gesture:
RangeError (index): Invalid value: Not in inclusive range 0..14: 15
When the exception was thrown, this was the stack:
#0 _Array.[] (dart:core-patch/array.dart:10:36)
#1 Proj4Crs.zoom (package:flutter_map/src/geo/crs/crs.dart:312:30)
#2 FlutterMapState.getScaleZoom (package:flutter_map/src/map/flutter_map_state.dart:569:16)
#3 FlutterMapState.getBoundsZoom (package:flutter_map/src/map/flutter_map_state.dart:541:12)
#4 FlutterMapState.getBoundsCenterZoom (package:flutter_map/src/map/flutter_map_state.dart:513:16)
#5 AnimatedMapController.flyToBounds (package:iops/layer/core/controller.dart:152:27)
... and when it doesn't throw an error, it gets completely incorrect coordinates. In part, this has to do with the fact that corner coordinates are not necessarily the bounds in a polar CRS. Especially dealing with longitudes is difficult. With either of the poles on the map for example, you have all longitudes possible in the pole, a single point.
There could potentially also be issues in the tile layer, which is using a similar approach for bounds checks, but I haven't encountered those issues personally.
What is the expected behaviour?
That fitBounds would work the same way regardless of CRS.
How can we reproduce this issue?
Try fitBounds in the EPSG:3413 example's initState (add mapController as class variable).
Incorrect position (should center on overlay image):
mapController = MapController();
WidgetsBinding.instance.addPostFrameCallback(
(_) => mapController.fitBounds(
LatLngBounds(
LatLng(72.7911372, 162.6196478),
LatLng(85.2802493, 79.794166),
),
),
);
Out of bounds:
mapController = MapController();
WidgetsBinding.instance.addPostFrameCallback(
(_) => mapController.fitBounds(
LatLngBounds(
LatLng(74.602998, -170.999769),
LatLng(74.602998, -170.999769),
),
),
);
Do you have a potential solution?
No response
Can you provide any other information?
Using the master version of flutter_map, but also present in older versions.
Platforms Affected
Android, iOS, Web, Windows, MacOS, Linux
Severity
Erroneous: Prevents normal functioning and causes errors in the console
Frequency
Consistently: Always occurs at the same time and location
Requirements
What is the bug?
In line with #1347 and #1295, there are more issues with bounds for polar CRS.
In some cases
fitBounds(and my copyflyToBounds) throws an error:... and when it doesn't throw an error, it gets completely incorrect coordinates. In part, this has to do with the fact that corner coordinates are not necessarily the bounds in a polar CRS. Especially dealing with longitudes is difficult. With either of the poles on the map for example, you have all longitudes possible in the pole, a single point.
There could potentially also be issues in the tile layer, which is using a similar approach for bounds checks, but I haven't encountered those issues personally.
What is the expected behaviour?
That
fitBoundswould work the same way regardless of CRS.How can we reproduce this issue?
Try
fitBoundsin the EPSG:3413 example'sinitState(addmapControlleras class variable).Incorrect position (should center on overlay image):
Out of bounds:
Do you have a potential solution?
No response
Can you provide any other information?
Using the
masterversion offlutter_map, but also present in older versions.Platforms Affected
Android, iOS, Web, Windows, MacOS, Linux
Severity
Erroneous: Prevents normal functioning and causes errors in the console
Frequency
Consistently: Always occurs at the same time and location
Requirements
flutter doctorfinds no relevant issues