1
私はmobx反応があり、条件付きでlayer.on({click})
関数をレイヤーグループにマップします。リーフレット - クリック時の上書きレイヤー
reaction(
() => this.managingDates,
() => {
if (this.managingDates) {
this.mapStore.polygonLayer.eachLayer(layer => {
layer.on({
click: e => {
this.mapStore.setManagedParcel({
feature: e.target.feature,
bounds: layer.getBounds()
});
layer.setStyle({
color: "red"
});
}
});
});
} else {
this.mapStore.polygonLayer.eachLayer(layer => {
layer.on({
click: e => {
this.mapStore.setActiveParcel(e.target.feature);
layer.setStyle({
color: "yellow"
});
}
});
});
}
}
);
これが初めて周りの罰金ですが、反応はなく、クリックイベントに上書きする、異なるパラメータで再起動したとき、第二の機能は、(その両方の機能をクリックで呼び出される)追加されます。
新しいレイヤーを追加する前に、以前のレイヤーをクリックして削除するにはどうすればよいですか?