Getting appropriate clusterZoom; flyto moving to incorrect location on map

This commit is contained in:
efarooqui
2020-09-30 13:07:29 -07:00
parent 5020e73811
commit 5333f492f8
4 changed files with 20 additions and 7 deletions

View File

@@ -27,6 +27,7 @@ class Map extends React.Component {
super()
this.projectPoint = this.projectPoint.bind(this)
this.locationToGeoJSON = this.locationToGeoJSON.bind(this)
this.onClusterSelect = this.onClusterSelect.bind(this)
this.svgRef = React.createRef()
this.map = null
this.index = null
@@ -188,6 +189,14 @@ class Map extends React.Component {
return feature
}
onClusterSelect (e) {
const { id } = e.target
const { longitude, latitude } = e.target.attributes
const { x, y } = this.projectPoint([latitude.value, longitude.value])
const expansionZoom = Math.max(this.index.getClusterExpansionZoom(parseInt(id)), this.index.options.minZoom)
this.map.flyTo([x, y], expansionZoom)
}
getClientDims () {
const boundingClient = document.querySelector(`#${this.props.ui.dom.map}`).getBoundingClientRect()
@@ -296,7 +305,7 @@ class Map extends React.Component {
projectPoint={this.projectPoint}
clusters={allClusters}
numClusters={allClusters.length}
// onSelect={() => {}}
onSelect={this.onClusterSelect}
/>
)
}