@@ -19,28 +19,10 @@ class _EPSG3413PageState extends State<EPSG3413Page> {
19
19
20
20
double ? maxZoom;
21
21
22
- // Define start center
23
- proj4.Point point = proj4.Point (x: 90 , y: 0 );
24
-
25
- String initText = 'Map centered to' ;
26
-
27
- late final proj4.Projection epsg4326;
28
-
29
- late final proj4.Projection epsg3413;
30
-
31
22
@override
32
23
void initState () {
33
24
super .initState ();
34
25
35
- epsg4326 = proj4.Projection .get ('EPSG:4326' )! ;
36
-
37
- // EPSG:3413 is a user-defined projection from a valid Proj4 definition string
38
- // From: http://epsg.io/3413, proj definition: http://epsg.io/3413.proj4
39
- // Find Projection by name or define it if not exists
40
- epsg3413 = proj4.Projection .get ('EPSG:3413' ) ??
41
- proj4.Projection .add ('EPSG:3413' ,
42
- '+proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs' );
43
-
44
26
// 9 example zoom level resolutions
45
27
final resolutions = < double > [
46
28
32768 ,
@@ -61,6 +43,13 @@ class _EPSG3413PageState extends State<EPSG3413Page> {
61
43
62
44
maxZoom = (resolutions.length - 1 ).toDouble ();
63
45
46
+ // EPSG:3413 is a user-defined projection from a valid Proj4 definition string
47
+ // From: http://epsg.io/3413, proj definition: http://epsg.io/3413.proj4
48
+ // Find Projection by name or define it if not exists
49
+ final proj4.Projection epsg3413 = proj4.Projection .get ('EPSG:3413' ) ??
50
+ proj4.Projection .add ('EPSG:3413' ,
51
+ '+proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs' );
52
+
64
53
epsg3413CRS = Proj4Crs .fromFactory (
65
54
code: 'EPSG:3413' ,
66
55
proj4Projection: epsg3413,
@@ -74,8 +63,26 @@ class _EPSG3413PageState extends State<EPSG3413Page> {
74
63
75
64
@override
76
65
Widget build (BuildContext context) {
66
+ // These circles should have the same pixel radius on the map
67
+ final circles = [
68
+ CircleMarker (
69
+ point: LatLng (90 , 0 ),
70
+ radius: 20000 ,
71
+ useRadiusInMeter: true ,
72
+ color: Colors .red,
73
+ )
74
+ ];
75
+ for (final lon in [- 90.0 , 0.0 , 90.0 , 180.0 ]) {
76
+ circles.add (CircleMarker (
77
+ point: LatLng (80 , lon),
78
+ radius: 20000 ,
79
+ useRadiusInMeter: true ,
80
+ color: Colors .red,
81
+ ));
82
+ }
83
+
77
84
return Scaffold (
78
- appBar: AppBar (title: const Text ('EPSG:4326 CRS' )),
85
+ appBar: AppBar (title: const Text ('EPSG:3413 CRS' )),
79
86
drawer: buildDrawer (context, EPSG3413Page .route),
80
87
body: Padding (
81
88
padding: const EdgeInsets .all (8.0 ),
@@ -92,23 +99,17 @@ class _EPSG3413PageState extends State<EPSG3413Page> {
92
99
),
93
100
),
94
101
),
95
- Padding (
96
- padding: const EdgeInsets .only (top: 8.0 , bottom: 2.0 ),
97
- child: Text (
98
- '$initText (${point .x .toStringAsFixed (5 )}, ${point .y .toStringAsFixed (5 )}) in EPSG:4326.' ,
99
- ),
100
- ),
101
- Padding (
102
- padding: const EdgeInsets .only (top: 2.0 , bottom: 2.0 ),
102
+ const Padding (
103
+ padding: EdgeInsets .only (top: 8.0 , bottom: 2.0 ),
103
104
child: Text (
104
- 'Which is (${ epsg4326 . transform ( epsg3413 , point ). x . toStringAsFixed ( 2 )}, ${ epsg4326 . transform ( epsg3413 , point ). y . toStringAsFixed ( 2 )}) in EPSG:3413 .' ,
105
+ 'This page demonstrates some tricky edge-cases for maps with a polar projection .' ,
105
106
),
106
107
),
107
108
Flexible (
108
109
child: FlutterMap (
109
110
options: MapOptions (
110
111
crs: epsg3413CRS,
111
- center: LatLng (point.x, point.y ),
112
+ center: LatLng (90 , 0 ),
112
113
zoom: 3.0 ,
113
114
maxZoom: maxZoom,
114
115
),
@@ -125,6 +126,22 @@ class _EPSG3413PageState extends State<EPSG3413Page> {
125
126
layers: ['gebco_north_polar_view' ],
126
127
),
127
128
),
129
+ CircleLayerOptions (
130
+ circles: circles,
131
+ ),
132
+ OverlayImageLayerOptions (
133
+ overlayImages: [
134
+ OverlayImage (
135
+ bounds: LatLngBounds (
136
+ LatLng (72.7911372 , 162.6196478 ),
137
+ LatLng (85.2802493 , 79.794166 ),
138
+ ),
139
+ imageProvider: Image .asset (
140
+ 'map/epsg3413/amsr2.png' ,
141
+ ).image,
142
+ )
143
+ ],
144
+ )
128
145
],
129
146
),
130
147
),
0 commit comments