You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Offline Leaflet Maps (should carry over to Mapbox too)
Image setup
Take a screenshot of the map in the position you need it in (ideally this shot would contain all sections of map that are relevant to the visualization)
Open the page in fullscreen and remove all elements that obstruct the map view, then screenshot
Get the coordinates of the current view's bounding box
Open devtools in a separate window. Make sure the map is still fullscreened.
This is important because otherwise the window size will be different than the screenshot size
In the console, run map.getBounds()
Save the ouput somewhere, this will be used later to position the image on the map
Leaflet setup
Remove all calls to functions that add tiles to the map
Set up the image:
varimgW=1920,// the width of the imageimgH=1080,// the height of the imageimgPath='../img/map-img.png';varimgBounds=newL.LatLngBounds([/*SW Lat from before*/,/*SW Lng from before*/],[/*NE Lat from before*/,/*NE Lng from before*/]);
Add the image to the map:
L.imageOverlay(imgPath,imgBounds);
Make sure Leaflet can't scroll past the edge of the image: