const TEMPLATE = document.createElement("template")
TEMPLATE.innerHTML = `
`
export class FeatureLegendElement extends HTMLElement {
feature
connectedCallback(){
if(!this.shadow){
this.shadow = this.attachShadow({mode: "open"})
this.shadow.append(TEMPLATE.content.cloneNode(true))
}
this.updateContent()
}
updateContent(){
let container = this.shadow.getElementById("legend-container")
let marker = this.shadow.getElementById("marker-icon")
container.hidden = !this.feature
if(this.feature){
let symbol = this.feature.mapSymbol
container.style.backgroundColor = symbol.backgroundColor || "transparent"
container.style.backgroundImage = symbol.backgroundUrl ? `url(${symbol.backgroundUrl})` : "none"
container.style.borderColor = symbol.borderColor || "transparent"
if(symbol.markerUrl){
marker.src = symbol.markerUrl
} else {
marker.removeAttribute("src")
}
}
}
}
customElements.define("camp-feature-legend", FeatureLegendElement)