Skip to content

Commit

Permalink
fix: can't set pin marker on fresh cluster #21
Browse files Browse the repository at this point in the history
  • Loading branch information
wazolab authored and frodrigo committed Oct 31, 2024
1 parent 309069a commit e4f005c
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/teritorio-cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,17 +274,22 @@ export class TeritorioCluster extends EventTarget {

if (featureIndex > -1) {
this.resetPinMarker()
const isUnfoldedCluster = clusterHTML.classList.contains(UnfoldedClusterClass)

// Get selected feature DOM element position within cluster
const selectedFeatureHTML = Array.from(clusterHTML.children).find(el => el.id === this.selectedFeatureId) as HTMLElement
if (!isUnfoldedCluster) {
this.pinMarker = this.renderPinMarker(marker.getLngLat()).addTo(this.map)
} else {
// Get selected feature DOM element position within cluster
const selectedFeatureHTML = Array.from(clusterHTML.children).find(el => el.id === this.selectedFeatureId) as HTMLElement

if (!selectedFeatureHTML)
throw new Error('Selected feature HTML marker was not found !')
if (!selectedFeatureHTML)
throw new Error('Selected feature HTML marker was not found !')

this.pinMarker = this.renderPinMarker(
marker.getLngLat(),
this._calculatePinMarkerOffset(clusterHTML, selectedFeatureHTML)
).addTo(this.map)
this.pinMarker = this.renderPinMarker(
marker.getLngLat(),
this._calculatePinMarkerOffset(clusterHTML, selectedFeatureHTML)
).addTo(this.map)
}
}
}

Expand Down

0 comments on commit e4f005c

Please sign in to comment.