<!DOCTYPE html> <html> <head> <title>Sketch HambiMap</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="w3.css"> <link rel="stylesheet" href="style.css"> <link href="fontawesome/5.3.1/css/all.css" rel="stylesheet"> <!--self-served leaflet--> <link rel="stylesheet" href="leaflet/Leaflet-1.9.4/leaflet.css"> <link rel="stylesheet" href="leaflet/leaflet-sidebar-v2/css/leaflet-sidebar.css"> </head> <body> <div id="sidebar" class="leaflet-sidebar collapsed"> <!-- nav tabs --> <div class="leaflet-sidebar-tabs"> <!-- top aligned tabs --> <ul role="tablist"> <li><a href="#home" role="tab"><i class="fa fa-bars active"></i></a></li> <li><a href="#autopan" role="tab"><i class="fa fa-arrows"></i></a></li> </ul> </div> <!-- panel content --> <div class="leaflet-sidebar-content"> <div class="leaflet-sidebar-pane" id="home"> <h1 class="leaflet-sidebar-header"> HambiMap Sketch <span class="leaflet-sidebar-close"><i class="fa fa-caret-left"></i></span> </h1> <p>A map designed to collect histories of Hambi treehouses</p> </div><!--sidebar-pane home--> </div><!--sidebar-content--> </div><!--sidebar--> <div id="map" style="height: 100vh;"></div> <script src="leaflet/Leaflet-1.9.4/leaflet.js"> <!--integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo="--> </script> <script src="leaflet/leaflet-sidebar-v2/js/leaflet-sidebar.js"></script> <script> var map = L.map('map').setView([50.880301, 6.560531], 13,); L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', { minZoom: 12, maxZoom: 19, attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>' }).addTo(map); var barrio_markers = L.layerGroup(); //overlay where all barrio markers will be added var tree_markers = L.layerGroup(); //overlay where all tree(house) markers will be added var test_tree_marker = L.marker([50.880301, 6.560531]).addTo(tree_markers); map.addLayer(tree_markers); function onMapClick(e){} //for adding a tree(house) function onMapZoom(e){ //for deciding wether to show barrios or treehouses if (map.getZoom() > 16) { map.addLayer(barrio_markers); map.removeLayer(tree_markers); } if (map.getZoom() <= 16) { map.addLayer(tree_markers); map.removeLayer(barrio_markers); } } function onMapMouseDown(e){} //probably needed for Barrio creation function onMapMouseUp(e){} //^^ function onMapContextMenu(e){}//probably neat for something map.on('click', onMapClick); map.on('zoomend', onMapZoom); map.on('mousedown', onMapMouseDown); map.on('mouseup', onMapMouseUp); map.on('contextMenu', onMapContextMenu); var sidebar = L.control.sidebar({ container: 'sidebar', // the DOM container or #ID of a predefined sidebar container that should be used }).addTo(map).open('home'); </script> </body> </html>