${site.name}
`
if (site.description) {
popupContent += `
${site.description}
`
}
if (site.address) {
popupContent += `
${site.address}
`
}
popupContent += `
${site.latitude.toFixed(4)}, ${site.longitude.toFixed(4)}
`
if (site.device_count > 0) {
popupContent += `
${site.device_count} device${site.device_count !== 1 ? 's' : ''}
`
}
popupContent += `
`
// Bind popup and attach event listener after marker is added to map
marker.bindPopup(popupContent)
marker.on('popupopen', () => {
const button = marker.getPopup()?.getElement()?.querySelector('[data-action="view-site"]') as HTMLElement
if (button) {
button.addEventListener('click', () => {
this.pushEvent("site_clicked", { site_id: button.dataset.siteId })
})
}
})
this.markers.addLayer(marker)
bounds.extend([site.latitude, site.longitude])
}
})
// Add markers to map
this.markers.addTo(this.map)
// Fit map to show all markers
if (bounds.isValid()) {
this.map.fitBounds(bounds, { padding: [20, 20] })
}
}
}
// Coverage hooks live in a separately-emitted chunk loaded only on
// pages that mount one of these hooks (coverage form, coverage show,
// coverage map). Reduces the main bundle by ~40 KB minified.
const CoverageLocationPicker = lazyHook(() => import("./hooks/coverage_hooks"), "CoverageLocationPicker")
const CoverageMap = lazyHook(() => import("./hooks/coverage_hooks"), "CoverageMap")
const MultiCoverageMap = lazyHook(() => import("./hooks/coverage_hooks"), "MultiCoverageMap")
const csrfToken = document.querySelector