Skip to content

Commit 19e9051

Browse files
committed
add better support for projections other than Web Mercator and Simple
1 parent 8df394d commit 19e9051

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

tests/bremen-sea-ice.html

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta name="viewport" content="width=device-width, initial-scale=1" />
5+
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.3/dist/leaflet.css" />
6+
<style>
7+
#map {
8+
bottom: 0;
9+
left: 0;
10+
position: absolute;
11+
right: 0;
12+
top: 0;
13+
}
14+
</style>
15+
</head>
16+
<body>
17+
<div id="map"></div>
18+
<script src="https://unpkg.com/browse/whatwg-fetch@3.2.0/dist/fetch.umd.js"></script>
19+
<script src="https://unpkg.com/leaflet@1.0.3/dist/leaflet.js"></script>
20+
<script src="https://unpkg.com/proj4"></script>
21+
<script src="https://unpkg.com/proj4leaflet@1.0.2"></script>
22+
<script src="https://unpkg.com/georaster"></script>
23+
<!-- <script src="https://unpkg.com/georaster-layer-for-leaflet"></script> -->
24+
<script src="/dist/v3/webpack/bundle/georaster-layer-for-leaflet.min.js"></script>
25+
<script src="https://unpkg.com/chroma-js"></script>
26+
<script type="module">
27+
// set CRS
28+
const EPSGRef = 'EPSG:3031'
29+
const proj4Definition =
30+
"+proj=stere +lat_0=-90 +lat_ts=-71 +lon_0=0 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs";
31+
const resolutions = [
32+
0,
33+
78271.484,
34+
33072.982812632297,
35+
16536.491406316149,
36+
8268.2457031580743,
37+
4134.1228515790372,
38+
2067.0614257895186,
39+
1033.5307128947593,
40+
516.76535644737965,
41+
258.38267822368982,
42+
129.19133911184491,
43+
64.595669555922456,
44+
32.297834777961228,
45+
16.148917388980614]
46+
47+
const crs = new L.Proj.CRS(EPSGRef, proj4Definition, {
48+
origin: [-8929486, 6564912],
49+
projectedBounds: L.bounds(L.point(-50, -38), L.point(130, -9)),
50+
resolutions: resolutions
51+
})
52+
53+
// initalize leaflet map
54+
var map = L.map("map", {
55+
crs,
56+
center: [-85.52885587994032,178.22048648568565],
57+
zoom: 7,
58+
minZoom: 2,
59+
maxZoom: 10
60+
})
61+
62+
// add AAD Polar Steregraphic Base Map
63+
if (new URLSearchParams(window.location.search).get("basemap") !== "off") {
64+
L.tileLayer('https://data.aad.gov.au/mbtileserver/services/tiles-newmap-12layers/tiles/{z}/{x}/{y}.png', {
65+
attribution: '&copy; <a href="https://data.aad.gov.au/map-attribution">Attribution</a>'
66+
}).addTo(map);
67+
}
68+
69+
var sea_ice = await parseGeoraster(window.location.origin + '/tests/bremen_sea_ice_conc_2022_9_9.tif');
70+
71+
var layer = new GeoRasterLayer({
72+
debugLevel: 10,
73+
georaster: sea_ice,
74+
resolution: 256
75+
});
76+
layer.addTo(map);
77+
const bounds = layer.getBounds();
78+
console.log("bounds:", bounds);
79+
map.fitBounds(bounds);
80+
</script>
81+
</body>
82+
</html>

0 commit comments

Comments
 (0)