Skip to content

Commit

Permalink
added dynamic label for marker icons
Browse files Browse the repository at this point in the history
  • Loading branch information
p3t3r67x0 committed Dec 2, 2024
1 parent a6c9d95 commit 578042d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,14 +340,17 @@ async function renderEnergyUnits(mapReference, municipalityKey) {
type: item.geojson.type,
coordinates: item.geojson.coordinates
},
properties: {}
properties: {
unitName: item.unit_name
}
}))
}

// Create a new GeoJSON layer
const newLayer = L.geoJSON(geoJsonData, {
pointToLayer(feature, latlng) {
const label = 'tbd. label'
const label = feature.properties.unitName

return L.marker(latlng, { icon: defaultIcon }).bindTooltip(label, {
permanent: false,
direction: 'top'
Expand Down Expand Up @@ -423,7 +426,7 @@ const updateSuggestions = (suggestions) => {


const fetchSuggestions = async (query) => {
if (!query) {
if (!query || query.length < 2) {
suggestionsList.classList.add('hidden')
suggestionsList.innerHTML = ''

Expand Down

0 comments on commit 578042d

Please sign in to comment.