Skip to content

Commit

Permalink
fix: no redeclare
Browse files Browse the repository at this point in the history
  • Loading branch information
trafficonese committed Jul 22, 2024
1 parent efd435f commit 44dd22f
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 51 deletions.
33 changes: 17 additions & 16 deletions inst/htmlwidgets/bindings/lfx-draw-bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,17 @@ LeafletWidget.methods.addDrawToolbar = function(targetLayerId,
options.edit = editOptions;

if (options && options.edittoolbar) {
var rtool = options.edittoolbar;
var tooldef = L.drawLocal.draw.toolbar;
L.drawLocal.edit.toolbar.buttons = Object.assign({}, tooldef.buttons, rtool.buttons);
L.drawLocal.edit.toolbar.actions = Object.assign({}, tooldef.actions, rtool.actions);
var edittool = options.edittoolbar;
var edittooldef = L.drawLocal.edit.toolbar;
L.drawLocal.edit.toolbar.buttons = Object.assign({}, edittooldef.buttons, edittool.buttons);
L.drawLocal.edit.toolbar.actions = Object.assign({}, edittooldef.actions, edittool.actions);
}

if (options && options.edithandlers) {
var rhand = options.edithandlers;
L.drawLocal.edit.handlers.edit = Object.assign({}, rhand.buttons, rtool.edit);
L.drawLocal.edit.handlers.remove = Object.assign({}, rhand.actions, rtool.remove);
var edithand = options.edithandlers;
var edithandledef = L.drawLocal.edit.handlers;
L.drawLocal.edit.handlers.edit = Object.assign({}, edithandledef.buttons, edithand.edit);
L.drawLocal.edit.handlers.remove = Object.assign({}, edithandledef.actions, edithand.remove);
}
}

Expand Down Expand Up @@ -140,13 +141,13 @@ LeafletWidget.methods.addDrawToolbar = function(targetLayerId,
map.drawToolbar.eventHandler.onDrawStart = function(e) {
if (!HTMLWidgets.shinyMode) return;
Shiny.onInputChange(map.id + '_draw_start', {'feature_type': e.layerType, 'nonce': Math.random()});
}
};
map.on(L.Draw.Event.DRAWSTART, map.drawToolbar.eventHandler.onDrawStart);

map.drawToolbar.eventHandler.onDrawStop = function(e) {
if (!HTMLWidgets.shinyMode) return;
Shiny.onInputChange(map.id + '_draw_stop', {'feature_type': e.layerType, 'nonce': Math.random()});
}
};
map.on(L.Draw.Event.DRAWSTOP, map.drawToolbar.eventHandler.onDrawStop);

map.drawToolbar.eventHandler.onCreated = function(e) {
Expand Down Expand Up @@ -196,19 +197,19 @@ LeafletWidget.methods.addDrawToolbar = function(targetLayerId,
layer.toGeoJSON(), {priority: 'event'});
Shiny.onInputChange(map.id + '_draw_all_features',
editableFeatureGroup.toGeoJSON(), {priority: 'event'});
}
};
map.on(L.Draw.Event.CREATED, map.drawToolbar.eventHandler.onCreated);

map.drawToolbar.eventHandler.onEditstart = function() {
if (!HTMLWidgets.shinyMode) return;
Shiny.onInputChange(map.id + '_draw_editstart', true, {priority: 'event'});
}
};
map.on(L.Draw.Event.EDITSTART, map.drawToolbar.eventHandler.onEditstart);

map.drawToolbar.eventHandler.onEditstop = function() {
if (!HTMLWidgets.shinyMode) return;
Shiny.onInputChange(map.id + '_draw_editstop', true, {priority: 'event'});
}
};
map.on(L.Draw.Event.EDITSTOP, map.drawToolbar.eventHandler.onEditstop);

map.drawToolbar.eventHandler.onEdited = function(e) {
Expand Down Expand Up @@ -236,19 +237,19 @@ LeafletWidget.methods.addDrawToolbar = function(targetLayerId,
layers.toGeoJSON(), {priority: 'event'});
Shiny.onInputChange(map.id + '_draw_all_features',
editableFeatureGroup.toGeoJSON(), {priority: 'event'});
}
};
map.on(L.Draw.Event.EDITED, map.drawToolbar.eventHandler.onEdited);

map.drawToolbar.eventHandler.onDeletestart = function() {
if (!HTMLWidgets.shinyMode) return;
Shiny.onInputChange(map.id + '_draw_deletestart', true, {priority: 'event'});
}
};
map.on(L.Draw.Event.DELETESTART, map.drawToolbar.eventHandler.onDeletestart);

map.drawToolbar.eventHandler.onDeletestop = function() {
if (!HTMLWidgets.shinyMode) return;
Shiny.onInputChange(map.id + '_draw_deletestop', true, {priority: 'event'});
}
};
map.on(L.Draw.Event.DELETESTOP, map.drawToolbar.eventHandler.onDeletestop);

map.drawToolbar.eventHandler.onDeleted = function(e) {
Expand All @@ -275,7 +276,7 @@ LeafletWidget.methods.addDrawToolbar = function(targetLayerId,
layers.toGeoJSON(), {priority: 'event'});
Shiny.onInputChange(map.id + '_draw_all_features',
editableFeatureGroup.toGeoJSON(), {priority: 'event'});
}
};
map.on(L.Draw.Event.DELETED, map.drawToolbar.eventHandler.onDeleted);

}).call(this);
Expand Down
68 changes: 34 additions & 34 deletions inst/htmlwidgets/bindings/lfx-search-bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,43 +21,43 @@ function eventToShiny(e) {

function adaptIcon(options) {
if (options.marker && options.marker.icon) {
var icon = options.marker.icon;
if (icon.awesomemarker) {
if (icon.squareMarker) {
icon.className = 'awesome-marker awesome-marker-square';
}
var icon = options.marker.icon;
if (icon.awesomemarker) {
if (icon.squareMarker) {
icon.className = 'awesome-marker awesome-marker-square';
}

if (!icon.prefix) {
icon.prefix = icon.library;
}
if (!icon.prefix) {
icon.prefix = icon.library;
}

return new L.AwesomeMarkers.icon(icon);
} else if (icon === true) {
return new L.Icon.Default();
} else {
// Unpack icons
icon.iconUrl = unpackStrings(icon.iconUrl);
icon.iconRetinaUrl = unpackStrings(icon.iconRetinaUrl);
icon.shadowUrl = unpackStrings(icon.shadowUrl);
icon.shadowRetinaUrl = unpackStrings(icon.shadowRetinaUrl);

if (icon.iconWidth) {
icon.iconSize = [icon.iconWidth, icon.iconHeight];
}
if (icon.shadowWidth) {
icon.shadowSize = [icon.shadowWidth, icon.shadowHeight];
}
if (icon.iconAnchorX) {
icon.iconAnchor = [icon.iconAnchorX, icon.iconAnchorY];
}
if (icon.shadowAnchorX) {
icon.shadowAnchor = [icon.shadowAnchorX, icon.shadowAnchorY];
}
if (icon.popupAnchorX) {
icon.popupAnchor = [icon.popupAnchorX, icon.popupAnchorY];
}
return new L.Icon(icon);
return new L.AwesomeMarkers.icon(icon);
} else if (icon === true) {
return new L.Icon.Default();
} else {
// Unpack icons
icon.iconUrl = unpackStrings(icon.iconUrl);
icon.iconRetinaUrl = unpackStrings(icon.iconRetinaUrl);
icon.shadowUrl = unpackStrings(icon.shadowUrl);
icon.shadowRetinaUrl = unpackStrings(icon.shadowRetinaUrl);

if (icon.iconWidth) {
icon.iconSize = [icon.iconWidth, icon.iconHeight];
}
if (icon.shadowWidth) {
icon.shadowSize = [icon.shadowWidth, icon.shadowHeight];
}
if (icon.iconAnchorX) {
icon.iconAnchor = [icon.iconAnchorX, icon.iconAnchorY];
}
if (icon.shadowAnchorX) {
icon.shadowAnchor = [icon.shadowAnchorX, icon.shadowAnchorY];
}
if (icon.popupAnchorX) {
icon.popupAnchor = [icon.popupAnchorX, icon.popupAnchorY];
}
return new L.Icon(icon);
}
}
}

Expand Down
Loading

0 comments on commit 44dd22f

Please sign in to comment.