Skip to content

Commit

Permalink
trial bind layer on events #38
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-salabim committed Feb 14, 2021
1 parent 89dcf63 commit c8e30dc
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions inst/htmlwidgets/lib/reactive/reactive.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,25 @@ LeafletWidget.methods.addReactiveLayer = function(x,
var cur_by = e.layer.feature.properties[by];
var ids = getAllIndexes(nkeys, cur_by);

e.target.eachLayer(function (layer) {
if(layer.feature.properties[[by]] == cur_by) {
layer.setStyle(layer.defaultOptions.style(layer.feature));
ids.forEach(function(i) {
if (map.hasLayer(bind_layer._layers[okeys[i]])) {
map.removeLayer(bind_layer._layers[okeys[i]]);
}
});

e.target.eachLayer(function (layer) {
layer.setStyle(layer.defaultOptions.style(layer.feature));
});

}
});

bind_layer.on(out, function (e) {
if (e.originalEvent.ctrlKey) {
// console.log(e.layer.feature.properties[by]);
var cur_by = e.layer.feature.properties[by];
var ids = getAllIndexes(nkeys, cur_by);

ids.forEach(function(i) {
if (map.hasLayer(bind_layer._layers[okeys[i]])) {
map.removeLayer(bind_layer._layers[okeys[i]]);
Expand Down

0 comments on commit c8e30dc

Please sign in to comment.