Skip to content

Commit

Permalink
feat: set pin marker on initial feature not in source #51
Browse files Browse the repository at this point in the history
  • Loading branch information
wazolab authored and frodrigo committed Dec 16, 2024
1 parent 1c62df5 commit 24db49d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/teritorio-cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,22 @@ export class TeritorioCluster extends EventTarget {
marker.remove()
}

if (this.initialFeature && !this.selectedFeatureId && !this.pinMarker) {
const id = this.#getFeatureId(this.initialFeature)
const coords = this.initialFeature.geometry.type === 'Point'
? new maplibre.LngLat(this.initialFeature.geometry.coordinates[0], this.initialFeature.geometry.coordinates[1])
: undefined

if (!coords) {
console.error(`Coordinates not found for feature id : ${id}`)
return
}

this.selectedFeatureId = id
this.#renderPinMarker(coords)
this.initialFeature = undefined
}

this.markersOnScreen = newMarkers
this.ticking = false
}
Expand Down

0 comments on commit 24db49d

Please sign in to comment.