2026-02-07 17:55:25 +00:00
|
|
|
{{ template "rmo/layout/base.html" . }}
|
2026-01-08 16:05:50 +00:00
|
|
|
|
2026-02-06 16:10:09 +00:00
|
|
|
{{ define "title" }}Report Nuisance{{ end }}
|
|
|
|
|
{{ define "extraheader" }}
|
2026-04-03 16:08:57 +00:00
|
|
|
<style></style>
|
2026-03-03 20:52:02 +00:00
|
|
|
<script
|
|
|
|
|
type="text/javascript"
|
|
|
|
|
src="//unpkg.com/maplibre-gl@5.0.1/dist/maplibre-gl.js"
|
|
|
|
|
></script>
|
2026-02-06 16:10:09 +00:00
|
|
|
<script src="/static/js/geocode.js"></script>
|
|
|
|
|
<script src="/static/js/location.js"></script>
|
|
|
|
|
<script src="/static/js/map-locator.js"></script>
|
|
|
|
|
<script src="/static/js/photo-upload.js"></script>
|
2026-03-09 18:02:22 +00:00
|
|
|
<script>
|
|
|
|
|
async function handleMapClick(mapLocator, lngLat) {
|
|
|
|
|
mapLocator.SetMarker(lngLat);
|
|
|
|
|
mapLocator.PanTo(lngLat, { duration: 2000 });
|
|
|
|
|
const response = await geocodeReverse({
|
|
|
|
|
lat: lngLat.lat,
|
|
|
|
|
lng: lngLat.lng,
|
|
|
|
|
});
|
|
|
|
|
console.log("click reverse geocode", response);
|
|
|
|
|
if (response !== undefined && response.features.length > 0) {
|
|
|
|
|
const addressInput = document.querySelector("address-input");
|
|
|
|
|
addressInput.SetValue(response.features[0]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
async function handleMarkerDrag(lngLat) {
|
|
|
|
|
const response = await geocodeReverse({
|
|
|
|
|
lat: lngLat.lat,
|
|
|
|
|
lng: lngLat.lng,
|
|
|
|
|
});
|
|
|
|
|
console.log("marker drag reverse geocode", response);
|
|
|
|
|
if (response !== undefined && response.features.length > 0) {
|
|
|
|
|
const addressInput = document.querySelector("address-input");
|
|
|
|
|
addressInput.SetValue(response.features[0]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Check for source identification
|
|
|
|
|
document.addEventListener("DOMContentLoaded", function () {
|
|
|
|
|
// Elements
|
|
|
|
|
const addressInput = document.querySelector("address-input");
|
|
|
|
|
const latitudeInput = document.getElementById("latitude");
|
|
|
|
|
const longitudeInput = document.getElementById("longitude");
|
|
|
|
|
const latlngAccuracyType = document.getElementById(
|
|
|
|
|
"latlng-accuracy-type",
|
|
|
|
|
);
|
|
|
|
|
const latlngAccuracyValue = document.getElementById(
|
|
|
|
|
"latlng-accuracy-value",
|
|
|
|
|
);
|
2026-02-06 16:10:09 +00:00
|
|
|
|
2026-03-09 18:02:22 +00:00
|
|
|
const mapLocator = document.querySelector("map-locator");
|
|
|
|
|
mapLocator.addEventListener("load", (event) => {
|
|
|
|
|
getGeolocation({
|
|
|
|
|
enableHighAccuracy: true,
|
|
|
|
|
timeout: 10000,
|
|
|
|
|
maximumAge: 0,
|
|
|
|
|
})
|
|
|
|
|
.then((position) => {
|
|
|
|
|
console.log("Got location", position);
|
|
|
|
|
latitudeInput.value = position.coords.latitude;
|
|
|
|
|
longitudeInput.value = position.coords.longitude;
|
|
|
|
|
latlngAccuracyType.value = "browser";
|
|
|
|
|
latlngAccuracyValue.value = position.coords.accuracy;
|
|
|
|
|
mapLocator.JumpTo({
|
|
|
|
|
center: {
|
|
|
|
|
lng: position.coords.longitude,
|
|
|
|
|
lat: position.coords.latitude,
|
|
|
|
|
},
|
|
|
|
|
zoom: 14,
|
|
|
|
|
});
|
|
|
|
|
const coords = [
|
|
|
|
|
position.coords.longitude,
|
|
|
|
|
position.coords.latitude,
|
|
|
|
|
];
|
|
|
|
|
mapLocator.SetMarker(coords);
|
|
|
|
|
mapLocator.JumpTo({ center: coords, zoom: 14 });
|
|
|
|
|
handleMarkerDrag({
|
|
|
|
|
lat: position.coords.latitude,
|
|
|
|
|
lng: position.coords.longitude,
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
console.log("location error", error);
|
|
|
|
|
});
|
2026-01-30 20:41:02 +00:00
|
|
|
});
|
2026-03-09 18:02:22 +00:00
|
|
|
let mapZoom = document.getElementById("map-zoom");
|
|
|
|
|
mapLocator.addEventListener("zoomend", function (e) {
|
|
|
|
|
mapZoom.value = e.target.GetZoom();
|
|
|
|
|
});
|
|
|
|
|
mapLocator.addEventListener("click", (e) => {
|
|
|
|
|
// We get some events without the lngLat
|
|
|
|
|
if (e.detail !== undefined && e.detail.lngLat !== undefined) {
|
|
|
|
|
handleMapClick(mapLocator, e.detail.lngLat);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
mapLocator.addEventListener("markerdragend", (e) => {
|
|
|
|
|
const marker = event.detail.marker;
|
|
|
|
|
const lngLat = marker.getLngLat();
|
|
|
|
|
handleMarkerDrag(lngLat);
|
2026-01-30 20:41:02 +00:00
|
|
|
});
|
|
|
|
|
|
2026-03-09 18:02:22 +00:00
|
|
|
const addressDisplay = document.querySelector("address-display");
|
|
|
|
|
addressInput.addEventListener("address-selected", (event) => {
|
|
|
|
|
const l = event.detail.location;
|
|
|
|
|
console.log("Address selected", l);
|
|
|
|
|
// Center map on selected address
|
|
|
|
|
mapLocator.SetMarker(l.geometry.coordinates);
|
|
|
|
|
mapLocator.JumpTo({
|
|
|
|
|
center: l.geometry.coordinates,
|
|
|
|
|
zoom: 14,
|
|
|
|
|
});
|
|
|
|
|
});
|
2026-03-09 22:22:04 +00:00
|
|
|
document.querySelectorAll(".source-card").forEach((card) => {
|
|
|
|
|
card.style.cursor = "pointer";
|
|
|
|
|
card.addEventListener("click", function (e) {
|
|
|
|
|
// Don't toggle if user clicked directly on the checkbox or label
|
|
|
|
|
if (e.target.type === "checkbox" || e.target.tagName === "LABEL") {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const checkbox = this.querySelector(".form-check-input");
|
|
|
|
|
checkbox.checked = !checkbox.checked;
|
|
|
|
|
|
|
|
|
|
// Trigger change event in case you have listeners on the checkbox
|
|
|
|
|
checkbox.dispatchEvent(new Event("change", { bubbles: true }));
|
|
|
|
|
});
|
|
|
|
|
});
|
2026-03-09 18:02:22 +00:00
|
|
|
});
|
|
|
|
|
</script>
|
2026-02-06 16:10:09 +00:00
|
|
|
<style></style>
|
|
|
|
|
{{ end }}
|