map: display popup on clicking marker or route

This commit is contained in:
desmukh 2023-01-31 16:24:39 +05:00
parent 8f7b53be73
commit 99bea6ae6c

View File

@ -32,8 +32,23 @@
var end = L.GeoJSON.coordsToLatLng({{ .endPoint.location }}); var end = L.GeoJSON.coordsToLatLng({{ .endPoint.location }});
var startMarker = L.marker(start).addTo(map); var startMarker = L.marker(start).addTo(map);
startMarker.bindPopup({{ .startingPoint.name }});
var endMarker = L.marker(end).addTo(map); var endMarker = L.marker(end).addTo(map);
var route = L.polyline([start, end], {color: 'red'}).addTo(map); endMarker.bindPopup({{ .endPoint.name }});
var route = L.polyline([start, end], {color: '#000'}).addTo(map);
var productsString = "";
var productsList = {{ .products }};
productsList.forEach((product, i) => productsString = productsString + product.productTitle + (i + 1 < productsList.length ? ', ' : ""));
route.bindPopup(
'<p>Origin: <strong>' + {{ .startingPoint.name }} + '</strong><br />' +
'Destination: <strong>' + {{ .endPoint.name }} + '</strong><br />' +
'Courier: <strong>' + {{ .courier.name }} + '</strong><br />' +
'Products: <strong>' + productsString + '</strong><br />' +
'Status: <strong>' + {{ .status }} + '</strong></p>');
{{ end }} {{ end }}
{{ end }} {{ end }}