Files
chrani-bot-tng/bot/modules/locations/templates/webmap/location_update_handler.html
2025-11-21 07:26:02 +01:00

33 lines
1.0 KiB
HTML

// Listen for location updates/additions
if (data.data_type === 'location_update' && data.payload && data.payload.location) {
const locationId = data.payload.location_id;
const loc = data.payload.location;
// Update locations dictionary with new data
locations[locationId] = loc;
// Remove old shape if exists
if (locationShapes[locationId]) {
map.removeLayer(locationShapes[locationId]);
delete locationShapes[locationId];
}
// Create new shape
try {
const shape = createLocationShape(locationId, loc);
locationShapes[locationId] = shape;
} catch (error) {
console.error('[MAP] Error updating location shape:', error);
}
}
// Listen for location removals
if (data.data_type === 'location_remove' && data.payload && data.payload.location_id) {
const locationId = data.payload.location_id;
if (locationShapes[locationId]) {
map.removeLayer(locationShapes[locationId]);
delete locationShapes[locationId];
}
}