Skip to content

Commit e2751ff

Browse files
committed
Fix plugins
Plugins are added to the LeafletWidget.methods object, but with the es2015 refactor I started using a different object which resulted in the plugins being ignored.
1 parent 1289845 commit e2751ff

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

inst/htmlwidgets/leaflet.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ require("./fixup-default-icon");
353353
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
354354

355355
window.LeafletWidget = {};
356-
window.LeafletWidget.methods = {};
356+
var methods = window.LeafletWidget.methods = _jquery2.default.extend({}, _methods2.default);
357357

358358
// Send updated bounds back to app. Takes a leaflet event object as input.
359359
function updateBounds(map) {
@@ -511,7 +511,7 @@ _htmlwidgets2.default.widget({
511511
}
512512
if (data.fitBounds) {
513513
explicitView = true;
514-
_methods2.default.fitBounds.apply(map, data.fitBounds);
514+
methods.fitBounds.apply(map, data.fitBounds);
515515
}
516516

517517
// Returns true if the zoomToLimits option says that the map should be
@@ -541,7 +541,7 @@ _htmlwidgets2.default.widget({
541541

542542
for (var i = 0; data.calls && i < data.calls.length; i++) {
543543
var call = data.calls[i];
544-
if (_methods2.default[call.method]) _methods2.default[call.method].apply(map, call.args);else (0, _util.log)("Unknown method " + call.method);
544+
if (methods[call.method]) methods[call.method].apply(map, call.args);else (0, _util.log)("Unknown method " + call.method);
545545
}
546546

547547
map.leafletr.hasRendered = true;
@@ -575,7 +575,7 @@ if (_htmlwidgets2.default.shinyMode) {
575575
if (call.dependencies) {
576576
_shiny2.default.renderDependencies(call.dependencies);
577577
}
578-
if (_methods2.default[call.method]) _methods2.default[call.method].apply(map, call.args);else (0, _util.log)("Unknown method " + call.method);
578+
if (methods[call.method]) methods[call.method].apply(map, call.args);else (0, _util.log)("Unknown method " + call.method);
579579
}
580580
});
581581
}

javascript/src/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import { log } from "./util";
88
import ControlStore from "./control-store";
99
import LayerManager from "./layer-manager";
1010

11-
import methods from "./methods";
11+
import defaultMethods from "./methods";
1212

1313
import "./fixup-default-icon";
1414

1515
window.LeafletWidget = {};
16-
window.LeafletWidget.methods = {};
16+
let methods = window.LeafletWidget.methods = $.extend({}, defaultMethods);
1717

1818
// Send updated bounds back to app. Takes a leaflet event object as input.
1919
function updateBounds(map) {
@@ -247,4 +247,4 @@ if (HTMLWidgets.shinyMode) {
247247
log("Unknown method " + call.method);
248248
}
249249
});
250-
}
250+
}

0 commit comments

Comments
 (0)