Skip to content

Instantly share code, notes, and snippets.

@shalevy1
Forked from dlferro/gist:3004639
Created January 10, 2023 18:59
Show Gist options
  • Select an option

  • Save shalevy1/c628866249a5c9788581fa95039acd65 to your computer and use it in GitHub Desktop.

Select an option

Save shalevy1/c628866249a5c9788581fa95039acd65 to your computer and use it in GitHub Desktop.
Leaflet Image Deepzoom
<html>
<head>
<link rel="stylesheet" href="lib/leaflet.css" />
<!--[if lte IE 8]>
<link rel="stylesheet" href="lib/leaflet.ie.css" />
<![endif]-->
</head>
<body>
<div id="map" style="width:1004px; height:748px; border: 1px solid black;"></div>
<script type="text/javascript" src="lib/leaflet-src.js"></script>
<script type="text/javascript">
var maxZoom = (data.length - 1), // contains the layer info
maxZoomLayer = data[data.length - 1]; // gets last zoom level object that contains height/width
// Setup the map
var map = new L.Map('map', {
crs: L.CRS.Simple,
worldCopyJump: false,
center: new L.LatLng(0.0, 0.0),
zoom: maxZoom,
maxZoom: maxZoom
});
// Immediately set the view with 0,0 on the top left
map.setView(map.layerPointToLatLng(new L.Point(1004, 748)), maxZoom, true); // bounds of container 1004/748
// Declare a tile layer and add to map
var tileURL = '/test/zoom{z}/row{y}/col{x}.png';
var tiles = new L.TileLayer(tileURL, {
noWrap: true,
maxZoom: maxZoom
});
map.addLayer(tiles);
// Reset the map to bound the image
map.fitBounds(new L.LatLngBounds(
map.layerPointToLatLng(new L.Point(0, maxZoomLayer.height)),
map.layerPointToLatLng(new L.Point(maxZoomLayer.width, 0))
));
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment