-
-
Save shalevy1/c628866249a5c9788581fa95039acd65 to your computer and use it in GitHub Desktop.
Leaflet Image Deepzoom
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <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