Style map markers to dots
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
5b5db0654e
commit
a15379a028
@ -1,8 +1,15 @@
|
|||||||
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css"
|
<link
|
||||||
integrity="sha256-kLaT2GOSpHechhsozzB+flnD+zUyjE2LlfWPgU04xyI=" crossorigin="" />
|
rel="stylesheet"
|
||||||
|
href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css"
|
||||||
|
integrity="sha256-kLaT2GOSpHechhsozzB+flnD+zUyjE2LlfWPgU04xyI="
|
||||||
|
crossorigin=""
|
||||||
|
/>
|
||||||
|
|
||||||
<script src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"
|
<script
|
||||||
integrity="sha256-WBkoXOwTeyKclOHuWtc+i2uENFpDZ9YPdf5Hf+D7ewM=" crossorigin=""></script>
|
src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"
|
||||||
|
integrity="sha256-WBkoXOwTeyKclOHuWtc+i2uENFpDZ9YPdf5Hf+D7ewM="
|
||||||
|
crossorigin=""
|
||||||
|
></script>
|
||||||
|
|
||||||
<div id="map"></div>
|
<div id="map"></div>
|
||||||
|
|
||||||
@ -12,6 +19,11 @@
|
|||||||
padding-bottom: 70%;
|
padding-bottom: 70%;
|
||||||
margin-bottom: 80px;
|
margin-bottom: 80px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.black-dot {
|
||||||
|
background-color: black;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@ -20,21 +32,33 @@
|
|||||||
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
|
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
var blackDotIcon = L.divIcon({
|
||||||
|
className: 'black-dot',
|
||||||
|
iconSize: [20, 20],
|
||||||
|
iconAnchor: [10, 10]
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// Create makers layer group
|
// Create makers layer group
|
||||||
var makers = L.layerGroup();
|
var makers = L.layerGroup();
|
||||||
{{ with getJSON "https://kios-admin.lumbung.space/api/makers"}}
|
{{ with getJSON "https://kios-admin.lumbung.space/api/makers"}}
|
||||||
{{ range .docs }}
|
{{ range .docs }}
|
||||||
var makerMarker = L.marker(L.GeoJSON.coordsToLatLng({{ .location }}));
|
var makerMarker = L.marker(L.GeoJSON.coordsToLatLng({{ .location }}), {
|
||||||
|
icon: blackDotIcon
|
||||||
|
});
|
||||||
makerMarker.bindPopup({{ .name }})
|
makerMarker.bindPopup({{ .name }})
|
||||||
makers.addLayer(makerMarker);
|
makers.addLayer(makerMarker);
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
// Create retailers layer group
|
// Create retailers layer group
|
||||||
var retailers = L.layerGroup();
|
var retailers = L.layerGroup();
|
||||||
{{ with getJSON "https://kios-admin.lumbung.space/api/retailers"}}
|
{{ with getJSON "https://kios-admin.lumbung.space/api/retailers"}}
|
||||||
{{ range .docs }}
|
{{ range .docs }}
|
||||||
var retailerMarker = L.marker(L.GeoJSON.coordsToLatLng({{ .location }}));
|
var retailerMarker = L.marker(L.GeoJSON.coordsToLatLng({{ .location }}), {
|
||||||
|
icon: blackDotIcon
|
||||||
|
});
|
||||||
retailerMarker.bindPopup({{ .name }})
|
retailerMarker.bindPopup({{ .name }})
|
||||||
retailers.addLayer(retailerMarker);
|
retailers.addLayer(retailerMarker);
|
||||||
{{ end }}
|
{{ end }}
|
||||||
@ -45,11 +69,11 @@
|
|||||||
{{ with getJSON "https://kios-admin.lumbung.space/api/dispatches"}}
|
{{ with getJSON "https://kios-admin.lumbung.space/api/dispatches"}}
|
||||||
{{ range .docs }}
|
{{ range .docs }}
|
||||||
var start = L.GeoJSON.coordsToLatLng({{ .startingPoint.location }});
|
var start = L.GeoJSON.coordsToLatLng({{ .startingPoint.location }});
|
||||||
var startMarker = L.marker(start);
|
var startMarker = L.marker(start, {icon: blackDotIcon});
|
||||||
startMarker.bindPopup({{ .startingPoint.name }});
|
startMarker.bindPopup({{ .startingPoint.name }});
|
||||||
|
|
||||||
var end = L.GeoJSON.coordsToLatLng({{ .endPoint.location }});
|
var end = L.GeoJSON.coordsToLatLng({{ .endPoint.location }});
|
||||||
var endMarker = L.marker(end);
|
var endMarker = L.marker(end, {icon: blackDotIcon});
|
||||||
endMarker.bindPopup({{ .endPoint.name }});
|
endMarker.bindPopup({{ .endPoint.name }});
|
||||||
|
|
||||||
// Add line to display dispatch route
|
// Add line to display dispatch route
|
||||||
@ -62,9 +86,9 @@
|
|||||||
productsList.forEach((product, i) => productsString = productsString + product.productTitle + (i + 1 < productsList.length ? ', ' : ""));
|
productsList.forEach((product, i) => productsString = productsString + product.productTitle + (i + 1 < productsList.length ? ', ' : ""));
|
||||||
|
|
||||||
route.bindPopup(
|
route.bindPopup(
|
||||||
'<p>Origin: <strong>' + {{ .startingPoint.name }} + '</strong><br />' +
|
'<p>Origin: <strong>' + {{ .startingPoint.name }} + '</strong><br />' +
|
||||||
'Destination: <strong>' + {{ .endPoint.name }} + '</strong><br />' +
|
'Destination: <strong>' + {{ .endPoint.name }} + '</strong><br />' +
|
||||||
'Courier: <strong>' + {{ .courier.name }} + '</strong><br />' +
|
'Courier: <strong>' + {{ .courier.name }} + '</strong><br />' +
|
||||||
'Products: <strong>' + productsString + '</strong><br />' +
|
'Products: <strong>' + productsString + '</strong><br />' +
|
||||||
'Status: <strong>' + {{ .status }} + '</strong></p>');
|
'Status: <strong>' + {{ .status }} + '</strong></p>');
|
||||||
|
|
||||||
@ -79,15 +103,15 @@
|
|||||||
zoom: 3,
|
zoom: 3,
|
||||||
layers: [osm, dispatches]
|
layers: [osm, dispatches]
|
||||||
});
|
});
|
||||||
|
|
||||||
var overlayMaps = {
|
var overlayMaps = {
|
||||||
"Dispatches": dispatches,
|
"Dispatches": dispatches,
|
||||||
"Makers": makers,
|
"Makers": makers,
|
||||||
"Retailers": retailers
|
"Retailers": retailers
|
||||||
};
|
};
|
||||||
|
|
||||||
var layerControl = L.control.layers(overlayMaps, null, {collapsed: false, position: "topleft"}).addTo(map);
|
var layerControl = L.control.layers(overlayMaps, null, {collapsed: false, position: "topleft"}).addTo(map);
|
||||||
window.addEventListener('load', (event) => {
|
window.addEventListener('load', (event) => {
|
||||||
map.invalidateSize();
|
map.invalidateSize();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user