HambiMap/sketch/html/main_with_sidebar.html

166 lines
6.6 KiB
HTML
Raw Normal View History

2023-06-28 15:38:18 +00:00
<!DOCTYPE html>
<html>
2023-06-30 16:46:32 +00:00
<head>
2023-06-28 15:38:18 +00:00
<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">
2023-07-01 09:25:56 +00:00
<link href="fontawesome/6.4.0/css/all.css" rel="stylesheet">
2023-06-28 15:38:18 +00:00
<!--self-served leaflet-->
<link rel="stylesheet" href="leaflet/Leaflet-1.9.4/leaflet.css">
2023-06-30 16:46:32 +00:00
<link rel="stylesheet" href="leaflet/leaflet-sidebar-v2/css/leaflet-sidebar.css">
</head>
<body>
<div id="sidebar" class="leaflet-sidebar collapsed">
2023-06-28 15:38:18 +00:00
2023-06-30 16:46:32 +00:00
<!-- 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>
2023-07-01 09:25:56 +00:00
<li><a href="#tree" role="tab"><i class="fa fa-tree"></i></a></li>
<li><a href="#barrio" role="tab"><i class="fa fa-tents"></i></a></li>
</ul>
<ul role="tablist">
<li><a href="#user" role="tab"><i class="fa fa-user"></i></a></li>
2023-06-30 16:46:32 +00:00
</ul>
</div>
2023-06-28 15:38:18 +00:00
2023-06-30 16:46:32 +00:00
<!-- 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>
2023-07-01 09:25:56 +00:00
<p>A map designed to collect histories of Hambi treehouses</p>
</div><!--sidebar-pane home-->
<div class="leaflet-sidebar-pane" id="tree">
<h1 class="leaflet-sidebar-header">
Treehouse (form)
<span class="leaflet-sidebar-close"><i class="fa fa-caret-left"></i></span>
</h1>
2023-07-10 14:46:40 +00:00
<p>Here you'll see a form to enter a new treehouse or the data about existing ones, depending on mode</p>
<iframe src="treehouse_form.html"></iframe>
2023-07-01 09:25:56 +00:00
</div><!--sidebar-pane tree_form-->
<div class="leaflet-sidebar-pane" id="barrio">
<h1 class="leaflet-sidebar-header">
Barrio (form)
<span class="leaflet-sidebar-close"><i class="fa fa-caret-left"></i></span>
</h1>
<p>Here you'll see a form to enter a new barrio or the data about existing ones, depending on mode</p>
</div><!--sidebar-pane barrio_form-->
<div class="leaflet-sidebar-pane" id="user">
<h1 class="leaflet-sidebar-header">
Login
<span class="leaflet-sidebar-close"><i class="fa fa-caret-left"></i></span>
</h1>
<p>here you'll see a login or user registration form, that we need for moderation privileges, and can use to save color/author name settings</p>
</div><!--sidebar-pane barrio_form-->
</div><!--sidebar-content-->
2023-06-30 16:46:32 +00:00
</div><!--sidebar-->
2023-06-28 15:38:18 +00:00
<div id="map" style="height: 100vh;"></div>
2023-06-30 16:46:32 +00:00
<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>
2023-07-10 14:46:40 +00:00
<script src="leaflet/Leaflet.SelectAreaFeature/src/Leaflet.SelectAreaFeature.js"></script>
2023-06-28 15:38:18 +00:00
<script>
2023-07-10 14:46:40 +00:00
const max_barrio_zoom = 16;
L.Control.EditButton = L.Control.extend({
onAdd: function (map) {
var editButton = L.DomUtil.create('button', 'w3-button w3-white w3-hover-light-blue w3-small leaflet-bar');
//var editButton = L.DomUtil.create('button', 'leaflet-bar leaflet-control leaflet-control-custom');
// editButton.style.backgroundColor = 'white';
// editButton.style.backgroundSize = "30px 30px";
let active = false;
let title_inactive_treehouse = 'Add a treehouse in the current map area';
let title_inactive_barrio = 'Add a barrio in the current map area';
let title_active = 'Disable edit mode to drag the map';
title_inactive = function(){
let zoom = map.getZoom();
if (zoom <= max_barrio_zoom) return title_inactive_barrio;
// if (layer == 'treehouse') // uncomment if you ever introduce another layer or default value
return title_inactive_treehouse;
};
editButton.innerHTML = 'edit';
editButton.title = title_inactive();
editButton.onclick = function(){
if (active) {
editButton.className = editButton.className.replace("w3-blue", "w3-white");
editButton.title = title_inactive();
map.selectAreaFeature.disable();
active = false;
} else {
editButton.className = editButton.className.replace("w3-white", "w3-blue");
editButton.title = title_active;
map.selectAreaFeature.enable();
active = true;
}
}
return editButton;
},
onRemove: function(map) {
// Nothing to do here
}
});
L.control.editButton = function(opts) {
return new L.Control.EditButton(opts);
}
2023-06-28 15:38:18 +00:00
var map = L.map('map').setView([50.880301, 6.560531], 13,);
2023-07-01 09:25:56 +00:00
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', { minZoom: 12, maxZoom: 19, attribution: 'Map data: &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap contributors</a>' }).addTo(map);
2023-07-10 14:46:40 +00:00
let editButton = L.control.editButton({position: 'topright'});
map.addControl(editButton,);
2023-06-28 15:38:18 +00:00
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
2023-07-10 14:46:40 +00:00
if (map.getZoom() > max_barrio_zoom) {
2023-06-28 15:38:18 +00:00
map.addLayer(barrio_markers);
map.removeLayer(tree_markers);
2023-07-10 14:46:40 +00:00
2023-06-28 15:38:18 +00:00
}
2023-07-10 14:46:40 +00:00
if (map.getZoom() <= max_barrio_zoom) {
2023-06-28 15:38:18 +00:00
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);
2023-06-30 16:46:32 +00:00
map.on('zoomend', onMapZoom);
2023-06-28 15:38:18 +00:00
map.on('mousedown', onMapMouseDown);
map.on('mouseup', onMapMouseUp);
map.on('contextMenu', onMapContextMenu);
2023-06-30 16:46:32 +00:00
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');
2023-06-28 15:38:18 +00:00
</script>
</body>
</html>