Skip to content

Commit

Permalink
add test html
Browse files Browse the repository at this point in the history
  • Loading branch information
Falke-Design committed Jul 13, 2023
1 parent 1af8eb0 commit a95d6cb
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions tests/caching.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="https://unpkg.com/leaflet/dist/leaflet.css" />
<style>
#map {
bottom: 0;
left: 0;
position: absolute;
right: 0;
top: 0;
}
</style>
</head>
<body>
<div id="map"></div>
<script src="https://unpkg.com/browse/[email protected]/dist/fetch.umd.js"></script>
<script src="https://unpkg.com/leaflet/dist/leaflet-src.js"></script>
<script src="https://unpkg.com/georaster"></script>
<script src="../dist/georaster-layer-for-leaflet.min.js"></script>
<script>
// initalize leaflet map
var map = L.map("map").setView([0, 0], 5);

// add OpenStreetMap basemap
L.tileLayer("http://{s}.tile.osm.org/{z}/{x}/{y}.png", {
attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);

var url_to_geotiff_file = "https://geotiff.github.io/georaster-layer-for-leaflet-example/example_4326.tif";

fetch(url_to_geotiff_file)
.then(function (response) {
return response.arrayBuffer();
})
.then(function (arrayBuffer) {
parseGeoraster(arrayBuffer).then(function (georaster) {
console.log("georaster:", georaster);
var layer = new GeoRasterLayer({
georaster: georaster,
resolution: {
0: 2, // Zoom level 0 or higher: resolution 2
16: 512 // Zoom level 16 or higher: resolution 512
},
caching: true
});
layer.addTo(map);
map.fitBounds(layer.getBounds());
});
});
</script>
</body>
</html>

0 comments on commit a95d6cb

Please sign in to comment.