map: change line appearance based on dispatch status

This commit is contained in:
desmukh 2023-02-08 16:51:46 +05:00
parent 5506d3cfa2
commit f241689eb7

View File

@ -53,7 +53,8 @@
endMarker.bindPopup({{ .endPoint.name }}); endMarker.bindPopup({{ .endPoint.name }});
// Add line to display dispatch route // Add line to display dispatch route
var route = L.polyline([start, end], {color: '#000'}) var myDashArray = {{ .status }} === "routeRequested" ? "20, 10" : {{ .status }} === "completed" ? "1, 5" : "0, 0"; // Dashed line based on status
var route = L.polyline([start, end], {color: '#000', dashArray: myDashArray });
// Generate string to display list of products in popup // Generate string to display list of products in popup
var productsString = ""; var productsString = "";
@ -76,13 +77,13 @@
var map = L.map('map', { var map = L.map('map', {
center: [0, 0], center: [0, 0],
zoom: 2, zoom: 2,
layers: [osm, makers] layers: [osm, dispatches]
}); });
var overlayMaps = { var overlayMaps = {
"Dispatches": dispatches,
"Makers": makers, "Makers": makers,
"Retailers": retailers, "Retailers": retailers
"Dispatches": dispatches
}; };
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);