Skip to content

Commit

Permalink
getSourceの仕様変更によりクラスタリングクリック時のズームが効かなくなっていたので修正
Browse files Browse the repository at this point in the history
  • Loading branch information
naogify committed Jul 30, 2024
1 parent 64f27dd commit b2daa49
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 b2daa49

Please sign in to comment.