Compare commits
2 Commits
dc5245d7cd
...
81b65968c6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
81b65968c6 | ||
|
|
61d96b30b9 |
@@ -6,8 +6,8 @@
|
||||
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
|
||||
<script src="jquery-3.7.1.min.js"></script>
|
||||
<script src="lib.js"></script>
|
||||
<script src="https://unpkg.com/maplibre-gl@3.1.0/dist/maplibre-gl.js"></script>
|
||||
<link href="https://unpkg.com/maplibre-gl@3.1.0/dist/maplibre-gl.css" rel="stylesheet">
|
||||
<script src="https://unpkg.com/maplibre-gl@5.5.0/dist/maplibre-gl.js"></script>
|
||||
<link href="https://unpkg.com/maplibre-gl@5.5.0/dist/maplibre-gl.css" rel="stylesheet">
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
@@ -19,24 +19,93 @@
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
}
|
||||
#features {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
width: 20%;
|
||||
overflow: auto;
|
||||
background: rgba(255, 255, 255, 0.8);
|
||||
}
|
||||
.maplibregl-popup {
|
||||
max-width: 200px;
|
||||
font: 12px/20px 'Helvetica Neue', Arial, Helvetica, sans-serif;
|
||||
}
|
||||
.rounded-rect {
|
||||
background: white;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 0 50px -25px black;
|
||||
}
|
||||
|
||||
.flex-center {
|
||||
position: absolute;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.flex-center.left {
|
||||
left: 0px;
|
||||
}
|
||||
|
||||
.sidebar-content {
|
||||
position: absolute;
|
||||
width: 95%;
|
||||
height: 95%;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
color: gray;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.sidebar-toggle {
|
||||
position: absolute;
|
||||
width: 1.3em;
|
||||
height: 1.3em;
|
||||
overflow: visible;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
font-size: 32px;
|
||||
}
|
||||
|
||||
.sidebar-toggle.left {
|
||||
right: -1.5em;
|
||||
}
|
||||
|
||||
.sidebar-toggle:hover {
|
||||
color: #0aa1cf;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
transition: transform 1s;
|
||||
z-index: 1;
|
||||
width: 300px;
|
||||
height: 100%;
|
||||
}
|
||||
#features {
|
||||
max-height: 50%;
|
||||
}
|
||||
|
||||
/*
|
||||
The sidebar styling has them "expanded" by default, we use CSS transforms to push them offscreen
|
||||
The toggleSidebar() function removes this class from the element in order to expand it.
|
||||
*/
|
||||
.left.collapsed {
|
||||
transform: translateX(-295px);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map"></div>
|
||||
<pre id="features"></pre>
|
||||
<div id="map">
|
||||
<div id="sidebarLeft" class="sidebar flex-center left">
|
||||
<div class="sidebar-content rounded-rect flex-center">
|
||||
<div>
|
||||
<input type="radio" name="planningMode" id="classicPlanning">classic</input>
|
||||
<input type="radio" name="planningMode" id="modernPlanning">modern</input>
|
||||
</div>
|
||||
<h2>Features</h2>
|
||||
<div id="features"></div>
|
||||
<div class="sidebar-toggle rounded-rect left"
|
||||
onclick="toggleSidebar('left')"
|
||||
>
|
||||
→
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
lib.init();
|
||||
</script>
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
const lib = new function () {
|
||||
|
||||
let ghbase = ""
|
||||
let planningMode = "modern";
|
||||
const modeContext = {
|
||||
"classic": '<button id="btn-feat">feature</button></br><button id="btn-start">start</button></br><button id="btn-via">via</button></br><button id="btn-finish">finish</button>',
|
||||
"modern": '<button id="btn-feat">feature</button></br><button id="btn-waypoint">waypoint</button>'
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize Map etc
|
||||
@@ -47,9 +52,10 @@ const lib = new function () {
|
||||
|
||||
const contextmenu = new maplibregl.Popup()
|
||||
.setLngLat(coordinates)
|
||||
.setHTML('<button id="btn-feat">feature</button></br><button id="btn-start">start</button></br><button id="btn-via">via</button></br><button id="btn-finish">finish</button>')
|
||||
.setHTML(modeContext[planningMode])
|
||||
.addTo(map);
|
||||
|
||||
if (planningMode === 'classic') {
|
||||
let featbtn = document.getElementById("btn-feat");
|
||||
featbtn.onclick = function () {
|
||||
contextmenu.remove();
|
||||
@@ -92,6 +98,28 @@ const lib = new function () {
|
||||
lib.doRouting(map, startMarker.getLngLat(), finishMarker.getLngLat(), viaMarkers);
|
||||
}
|
||||
};
|
||||
} else if (planningMode === 'modern') {
|
||||
let waypointbtn = document.getElementById("btn-waypoint");
|
||||
waypointbtn.onclick = function () {
|
||||
contextmenu.remove();
|
||||
if (!startMarker.onMap) {
|
||||
startMarker.setLngLat([coordinates.lng, coordinates.lat]).addTo(map);
|
||||
startMarker.onMap = true;
|
||||
} else if (!finishMarker.onMap) {
|
||||
finishMarker.setLngLat([coordinates.lng, coordinates.lat]).addTo(map);
|
||||
finishMarker.onMap = true;
|
||||
lib.doRouting(map, startMarker.getLngLat(), coordinates);
|
||||
} else {
|
||||
const oldFinishMarker = new maplibregl.Marker({color: "#0000FF", draggable: true}).setLngLat(finishMarker.getLngLat());
|
||||
finishMarker.setLngLat([coordinates.lng, coordinates.lat]);
|
||||
oldFinishMarker.on("dragend", function() {lib.doRouting(map, startMarker.getLngLat(), finishMarker.getLngLat(), viaMarkers);});
|
||||
oldFinishMarker.addTo(map);
|
||||
oldFinishMarker.onMap = true;
|
||||
viaMarkers.push(oldFinishMarker);
|
||||
lib.doRouting(map, startMarker.getLngLat(), finishMarker.getLngLat(), viaMarkers);
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -148,4 +176,7 @@ const lib = new function () {
|
||||
dataType: "json"
|
||||
});
|
||||
};
|
||||
|
||||
this.togglePlanningMode = function () {
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user