dawarich/app/javascript/maps_v2/layers/areas_layer.js

68 lines
1.3 KiB
JavaScript
Raw Normal View History

2025-11-20 17:46:06 -05:00
import { BaseLayer } from './base_layer'
/**
* Areas layer for user-defined regions
*/
export class AreasLayer extends BaseLayer {
constructor(map, options = {}) {
super(map, { id: 'areas', ...options })
}
getSourceConfig() {
return {
type: 'geojson',
data: this.data || {
type: 'FeatureCollection',
features: []
}
}
}
getLayerConfigs() {
return [
// Area fills
{
id: `${this.id}-fill`,
type: 'fill',
source: this.sourceId,
paint: {
2025-11-30 07:37:03 -05:00
'fill-color': '#ff0000',
'fill-opacity': 0.4
2025-11-20 17:46:06 -05:00
}
},
// Area outlines
{
id: `${this.id}-outline`,
type: 'line',
source: this.sourceId,
paint: {
2025-11-30 07:37:03 -05:00
'line-color': '#ff0000',
'line-width': 3
2025-11-20 17:46:06 -05:00
}
},
// Area labels
{
id: `${this.id}-labels`,
type: 'symbol',
source: this.sourceId,
layout: {
'text-field': ['get', 'name'],
'text-font': ['Open Sans Bold', 'Arial Unicode MS Bold'],
'text-size': 14
},
paint: {
'text-color': '#111827',
'text-halo-color': '#ffffff',
'text-halo-width': 2
}
}
]
}
getLayerIds() {
return [`${this.id}-fill`, `${this.id}-outline`, `${this.id}-labels`]
}
}