Skip to content

Commit

Permalink
Merge pull request #398 from geolonia/fix-cluster-zoom
Browse files Browse the repository at this point in the history
クラスタリングクリック時のズームが効かなくなっていたので修正
  • Loading branch information
keichan34 authored Oct 25, 2024
2 parents dbec829 + 5a29938 commit e6e66ce
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/lib/simplestyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,17 +304,14 @@ export class SimpleStyle {
},
});

this.map.on('click', `${this.options.id}-clusters`, (e) => {
this.map.on('click', `${this.options.id}-clusters`, async (e) => {
const features = this.map.queryRenderedFeatures(e.point, { layers: [`${this.options.id}-clusters`] });
const clusterId = features[0].properties.cluster_id;
this.map.getSource(`${this.options.id}-points`).getClusterExpansionZoom(clusterId, (err, zoom) => {
if (err)
return;

this.map.easeTo({
center: features[0].geometry.coordinates,
zoom: zoom,
});
const zoom = await this.map.getSource(`${this.options.id}-points`).getClusterExpansionZoom(clusterId);

this.map.easeTo({
center: features[0].geometry.coordinates,
zoom: zoom,
});
});

Expand Down

0 comments on commit e6e66ce

Please sign in to comment.