Custom CRSs
Projection
To define a Proj4Crs
(custom CRS) you have to register a projection of proj4.Projection
. For that you must import proj4dart
library as follows:
You can create and register your custom projection in multiple ways, but the recommended is to use a Proj4 definition string from epsg.io. For example for EPSG:3413
(WGS 84 / NSIDC Sea Ice Polar Stereographic North) you can find it here. This is how a Proj4 definition string looks like:
With this Proj4 definition string and a string identifier register your proj4.Projection
like this:
For more possible ways to register proj4.Projection
see proj4dart documentation.
Coordinate Reference System (CRS)
You can use your previously registered proj4.Projection
to create a custom CRS of type Proj4Crs
. You can use the following parameters:
<String>
code
(required): string identifier for the selected CRS, e.g.EPSG:3413
<proj4.Projection>
proj4Projection
(required): theproj4.Projection
object you wish to use<Bounds>
bounds
: bounds of the CRS in projected coordinates<List<double>>
resolutions
: an array of zoom factors (projection units per pixel, eg. meters/pixel)<List<double>>
scales
: scale factors (pixels per projection unit); specify either scales or resolutions, but not both!<List<Point>>
origins
: tile origin in projected coordinates (for TileLayer). Why is it needed? GeoServer by default can define different origins (top left coordinates) for each zoom levels. In case of origin mismatch the tile will be drawn on the wrong place: the map will jump at such zoom levels. If your origins vary with zoom levels the number of origins must match the number of resolutions. You can get the desired origins from aGetCapabilities
WMTS call from geoserver e.g.http://[ip:port]/geoserver/gwc/service/wmts?request=GetCapabilities
. This results an XML, and you have to look up for theTopLeftCorner
s for each TileMatrix of your TileMatrixSet.<Transformation>
transformation
: the transformation to use when transforming projected coordinates into pixel coordinates
An example:
Usage
Proj4Crs has multiple uses:
Set
FlutterMap
's default CRS:Set a WMS layer's CRS
For complete code (with point transformation from one projection to another) see the page source code. This is how it looks like:
Last updated