I’m trying to setup a custom CRS in flutter_map to cover a small area with a different coordinate system. I’ve setup a proj4 CRS as below:
final epsg27700 = proj4.Projection.get('EPSG:27700') ?? proj4.Projection.add('EPSG:27700', '+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894 +units=m +no_defs');
final resolutions = zoomLevels.map<double>((level) => level.resolution).toList();
final crs = Proj4Crs.fromFactory(
code: 'EPSG:27700',
proj4Projection: epsg27700,
resolutions: resolutions,
bounds: bounds,
origins: [
Point(
bounds.topLeft.x,
bounds.bottomRight.y,
)
],
);
Then loaded into the map:
FlutterMap(
mapController: widget.mapController.mapController,
options: MapOptions(
crs: _projection,
initialCenter: _tileProvider.mapCenter,
minZoom: 0,
maxZoom: 2,
),
children: [
TileLayer(
zoomReverse: true,
tileProvider: _tileProvider,
tileBounds: _tileBounds,
)
],
),
This works correctly on first load but when I try to zoom in or out, I get the following:
Invalid value: Not in inclusive range 0..2: 3)
It seems to be that it’s trying to load resolutions outside of the ones specified. There are only 3 resolutions specified for the 3 different levels in the map file. As you can see I have specified the maxZoom at 2 but it’s attempting to find a resolution at index 3.
There’s no clear documentation on how the resolutions relate to min/maxZoom or min/maxNativeZoom or the available tile levels that I can find so I may be doing something incorrectly here.