fix(map): selectFeature event handling - unify payload format for map click and feature table

- FeatureTable: dispatch { featureId } object instead of raw ID
- ProjectMap: selectFeature listener accepts both formats (direct ID or { featureId })
- project-map.blade.php: move selectFeature inside livewire:init handler so Livewire.emit is available
- Added logging for debugging

Fixes: 'Livewire.emit is not a function' on map click and 'Only arrays and Traversables can be unpacked' on table button
This commit is contained in:
Javier Braña
2026-08-24 11:12:32 +02:00
parent 534d9f8eab
commit c58a49f22d
3 changed files with 25 additions and 14 deletions
@@ -724,10 +724,6 @@
}
}
function selectFeature(featureId) {
Livewire.emit('map-select-feature', featureId);
}
function getUserLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition((pos) => {
@@ -743,6 +739,12 @@
document.addEventListener('livewire:init', function () {
setTimeout(initMap, 50);
// Define selectFeature here so Livewire is guaranteed to be available
window.selectFeature = function(featureId) {
console.log('selectFeature called with:', featureId);
Livewire.emit('map-select-feature', { featureId: featureId });
};
Livewire.on('layersUpdated', (activeIds) => {
const ids = Array.isArray(activeIds) ? activeIds[0] : activeIds;
for (let id in layers) {