From 57f15212442047aa329fa8172f2d205620537369 Mon Sep 17 00:00:00 2001 From: Sebastian Gatscha Date: Sat, 16 Mar 2024 09:55:41 +0100 Subject: [PATCH] JS linting and add Styler GHA --- .eslintrc.js | 36 ++++++++ .github/workflows/styler.yaml | 75 +++++++++++++++ inst/htmlwidgets/bindings/.eslintrc.js | 33 ------- .../bindings/lfx-bouncemarker-bindings.js | 92 +++++++++---------- .../htmlwidgets/bindings/lfx-draw-bindings.js | 58 +++--------- inst/htmlwidgets/bindings/lfx-gps-bindings.js | 2 +- .../bindings/lfx-omnivore-bindings.js | 2 +- .../bindings/lfx-pulse-icon-bindings.js | 4 +- .../bindings/lfx-search-bindings.js | 20 ++-- .../bindings/lfx-wms-legend-bindings.js | 14 +-- .../lfx-bouncemarker-bindings.js | 2 +- .../lfx-bouncemarker-bindings.js.map | 2 +- .../build/lfx-draw/lfx-draw-bindings.js | 2 +- .../build/lfx-draw/lfx-draw-bindings.js.map | 2 +- .../build/lfx-gps/lfx-gps-bindings.js | 2 +- .../build/lfx-gps/lfx-gps-bindings.js.map | 2 +- .../build/lfx-search/lfx-search-bindings.js | 2 +- .../lfx-search/lfx-search-bindings.js.map | 2 +- .../lfx-wms-legend-bindings.js.map | 2 +- package.json | 3 +- webpack.config.js | 2 +- 21 files changed, 204 insertions(+), 155 deletions(-) create mode 100644 .eslintrc.js create mode 100644 .github/workflows/styler.yaml delete mode 100644 inst/htmlwidgets/bindings/.eslintrc.js diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 00000000..2a13f29c --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,36 @@ +module.exports = { + "parserOptions": { + "ecmaVersion": 6 + }, + "extends": "eslint:recommended", + "rules": { + "indent": [ + "error", + 2 + ], + "linebreak-style": "off", // Disable linebreak style rule + "quotes": [ + "error", + "single" + ], + "semi": [ + "error", + "always" + ], + "no-unused-vars": [ + "error", + {"args": "none"} + ], + "no-console": "off", + "no-restricted-syntax": [ + "error", + { + "selector": "CallExpression[callee.object.name='console'][callee.property.name!=/^(log|warn|error|info|trace)$/]", + "message": "Unexpected property on console object was called" + } + ], + "no-var": "off", // Allow var declarations + "prefer-const": "error", // Enforce the use of const where possible + "no-assign-const": "off" + } +}; diff --git a/.github/workflows/styler.yaml b/.github/workflows/styler.yaml new file mode 100644 index 00000000..caed47f2 --- /dev/null +++ b/.github/workflows/styler.yaml @@ -0,0 +1,75 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + paths: ["**.[rR]", "**.[qrR]md", "**.[rR]markdown", "**.[rR]nw", "**.[rR]profile"] + +name: Style + +jobs: + style: + runs-on: ubuntu-latest + permissions: + contents: write + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - name: Checkout repo + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup R + uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - name: Install dependencies + uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::styler, any::roxygen2 + needs: styler + + - name: Enable styler cache + run: styler::cache_activate() + shell: Rscript {0} + + - name: Determine cache location + id: styler-location + run: | + cat( + "location=", + styler::cache_info(format = "tabular")$location, + "\n", + file = Sys.getenv("GITHUB_OUTPUT"), + append = TRUE, + sep = "" + ) + shell: Rscript {0} + + - name: Cache styler + uses: actions/cache@v4 + with: + path: ${{ steps.styler-location.outputs.location }} + key: ${{ runner.os }}-styler-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-styler- + ${{ runner.os }}- + + - name: Style + run: styler::style_pkg() + shell: Rscript {0} + + - name: Commit and push changes + run: | + if FILES_TO_COMMIT=($(git diff-index --name-only ${{ github.sha }} \ + | egrep --ignore-case '\.(R|[qR]md|Rmarkdown|Rnw|Rprofile)$')) + then + git config --local user.name "$GITHUB_ACTOR" + git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" + git commit ${FILES_TO_COMMIT[*]} -m "Style code (GHA)" + git pull --ff-only + git push origin + else + echo "No changes to commit." + fi diff --git a/inst/htmlwidgets/bindings/.eslintrc.js b/inst/htmlwidgets/bindings/.eslintrc.js deleted file mode 100644 index 20b119bc..00000000 --- a/inst/htmlwidgets/bindings/.eslintrc.js +++ /dev/null @@ -1,33 +0,0 @@ -module.exports = { - "env": { - "browser": true, - "es6": false - }, - "extends": "eslint:recommended", - "rules": { - "indent": [ - "error", - 2 - ], - "linebreak-style": [ - "error", - "unix" - ], - "quotes": [ - "error", - "single" - ], - "semi": [ - "error", - "always" - ], - "no-unused-vars": [ - "error", - {"args": "none"} - ], - "no-console": [ - "warn", - {} - ] - } -}; diff --git a/inst/htmlwidgets/bindings/lfx-bouncemarker-bindings.js b/inst/htmlwidgets/bindings/lfx-bouncemarker-bindings.js index ed45d0f9..b1d14256 100644 --- a/inst/htmlwidgets/bindings/lfx-bouncemarker-bindings.js +++ b/inst/htmlwidgets/bindings/lfx-bouncemarker-bindings.js @@ -1,4 +1,4 @@ -/* global LeafletWidget, L */ +/* global LeafletWidget, $, L */ function asArray(value) { if (value instanceof Array) @@ -10,7 +10,7 @@ function unpackStrings(iconset) { if (!iconset) { return iconset; } - if (typeof(iconset.index) === "undefined") { + if (typeof(iconset.index) === 'undefined') { return iconset; } @@ -30,46 +30,47 @@ LeafletWidget.methods.addBounceMarkers = function( let icondf; let getIcon; + if (icon) { - // Unpack icons - icon.iconUrl = unpackStrings(icon.iconUrl); - icon.iconRetinaUrl = unpackStrings(icon.iconRetinaUrl); - icon.shadowUrl = unpackStrings(icon.shadowUrl); - icon.shadowRetinaUrl = unpackStrings(icon.shadowRetinaUrl); - - // This cbinds the icon URLs and any other icon options; they're all - // present on the icon object. - icondf = new LeafletWidget.DataFrame().cbind(icon); - - // Constructs an icon from a specified row of the icon dataframe. - getIcon = function(i) { - let opts = icondf.get(i); - if (!opts.iconUrl) { - return new L.Icon.Default(); - } - - // Composite options (like points or sizes) are passed from R with each - // individual component as its own option. We need to combine them now - // into their composite form. - if (opts.iconWidth) { - opts.iconSize = [opts.iconWidth, opts.iconHeight]; - } - if (opts.shadowWidth) { - opts.shadowSize = [opts.shadowWidth, opts.shadowHeight]; - } - if (opts.iconAnchorX) { - opts.iconAnchor = [opts.iconAnchorX, opts.iconAnchorY]; - } - if (opts.shadowAnchorX) { - opts.shadowAnchor = [opts.shadowAnchorX, opts.shadowAnchorY]; - } - if (opts.popupAnchorX) { - opts.popupAnchor = [opts.popupAnchorX, opts.popupAnchorY]; - } - - return new L.Icon(opts); - }; - } + // Unpack icons + icon.iconUrl = unpackStrings(icon.iconUrl); + icon.iconRetinaUrl = unpackStrings(icon.iconRetinaUrl); + icon.shadowUrl = unpackStrings(icon.shadowUrl); + icon.shadowRetinaUrl = unpackStrings(icon.shadowRetinaUrl); + + // This cbinds the icon URLs and any other icon options; they're all + // present on the icon object. + icondf = new LeafletWidget.DataFrame().cbind(icon); + + // Constructs an icon from a specified row of the icon dataframe. + getIcon = function(i) { + var opts = icondf.get(i); + if (!opts.iconUrl) { + return new L.Icon.Default(); + } + + // Composite options (like points or sizes) are passed from R with each + // individual component as its own option. We need to combine them now + // into their composite form. + if (opts.iconWidth) { + opts.iconSize = [opts.iconWidth, opts.iconHeight]; + } + if (opts.shadowWidth) { + opts.shadowSize = [opts.shadowWidth, opts.shadowHeight]; + } + if (opts.iconAnchorX) { + opts.iconAnchor = [opts.iconAnchorX, opts.iconAnchorY]; + } + if (opts.shadowAnchorX) { + opts.shadowAnchor = [opts.shadowAnchorX, opts.shadowAnchorY]; + } + if (opts.popupAnchorX) { + opts.popupAnchor = [opts.popupAnchorX, opts.popupAnchorY]; + } + + return new L.Icon(opts); + }; + } if(!($.isEmptyObject(lat) || $.isEmptyObject(lng)) || ($.isNumeric(lat) && $.isNumeric(lng))) { @@ -88,18 +89,17 @@ LeafletWidget.methods.addBounceMarkers = function( if (icon) icondf.effectiveLength = df.nrow(); LeafletWidget.methods.addGenericMarkers( - this, df, group, clusterOptions, clusterId, (df, i) => { + this, df, group, clusterOptions, clusterId, function(df, i) { var options = df.get(i); if (icon) options.icon = getIcon(i); options.bounceOnAdd = true; options.bounceOnAddOptions = { - duration: duration, - height: height + duration: duration, + height: height }; return L.marker([df.get(i, 'lat'), df.get(i, 'lng')], options); }); } - } - ).call(this); + }).call(this); }; diff --git a/inst/htmlwidgets/bindings/lfx-draw-bindings.js b/inst/htmlwidgets/bindings/lfx-draw-bindings.js index bf76abfc..87a9f08e 100644 --- a/inst/htmlwidgets/bindings/lfx-draw-bindings.js +++ b/inst/htmlwidgets/bindings/lfx-draw-bindings.js @@ -72,50 +72,20 @@ LeafletWidget.methods.addDrawToolbar = function(targetLayerId, targetGroup, opti if (options && options.toolbar) { var rtool = options.toolbar; var tooldef = L.drawLocal.draw.toolbar; - L.drawLocal.draw.toolbar.buttons = { - ...tooldef.buttons, - ...rtool.buttons - }; - L.drawLocal.draw.toolbar.actions = { - ...tooldef.actions, - ...rtool.actions - }; - L.drawLocal.draw.toolbar.finish = { - ...tooldef.finish, - ...rtool.finish - }; - L.drawLocal.draw.toolbar.undo = { - ...tooldef.undo, - ...rtool.undo - }; + L.drawLocal.draw.toolbar.buttons = Object.assign({}, tooldef.buttons, rtool.buttons); + L.drawLocal.draw.toolbar.actions = Object.assign({}, tooldef.actions, rtool.actions); + L.drawLocal.draw.toolbar.finish = Object.assign({}, tooldef.finish, rtool.finish); + L.drawLocal.draw.toolbar.undo = Object.assign({}, tooldef.undo, rtool.undo); } if (options && options.handlers) { var rhand = options.handlers; var handldef = L.drawLocal.draw.handlers; - L.drawLocal.draw.handlers.circle = { - ...handldef.circle, - ...rhand.circle - }; - L.drawLocal.draw.handlers.circlemarker = { - ...handldef.circlemarker, - ...rhand.circlemarker - }; - L.drawLocal.draw.handlers.marker = { - ...handldef.marker, - ...rhand.marker - }; - L.drawLocal.draw.handlers.polygon = { - ...handldef.polygon, - ...rhand.polygon - }; - L.drawLocal.draw.handlers.polyline = { - ...handldef.polyline, - ...rhand.polyline - }; - L.drawLocal.draw.handlers.rectangle = { - ...handldef.rectangle, - ...rhand.rectangle - }; + L.drawLocal.draw.handlers.circle = Object.assign({}, handldef.circle, rhand.circle); + L.drawLocal.draw.handlers.circlemarker = Object.assign({}, handldef.circlemarker, rhand.circlemarker); + L.drawLocal.draw.handlers.marker = Object.assign({}, handldef.marker, rhand.marker); + L.drawLocal.draw.handlers.polygon = Object.assign({}, handldef.polygon, rhand.polygon); + L.drawLocal.draw.handlers.polyline = Object.assign({}, handldef.polyline, rhand.polyline); + L.drawLocal.draw.handlers.rectangle = Object.assign({}, handldef.rectangle, rhand.rectangle); } // Create new Drawing Control @@ -167,11 +137,11 @@ LeafletWidget.methods.addDrawToolbar = function(targetLayerId, targetGroup, opti editableFeatureGroup.toGeoJSON()); }); - map.on(L.Draw.Event.EDITSTART, function (e) { + map.on(L.Draw.Event.EDITSTART, function () { if (!HTMLWidgets.shinyMode) return; Shiny.onInputChange(map.id+'_draw_editstart', true); }); - map.on(L.Draw.Event.EDITSTOP, function (e) { + map.on(L.Draw.Event.EDITSTOP, function () { if (!HTMLWidgets.shinyMode) return; Shiny.onInputChange(map.id+'_draw_editstop', true); }); @@ -201,12 +171,12 @@ LeafletWidget.methods.addDrawToolbar = function(targetLayerId, targetGroup, opti editableFeatureGroup.toGeoJSON()); }); - map.on(L.Draw.Event.DELETESTART, function (e) { + map.on(L.Draw.Event.DELETESTART, function () { if (!HTMLWidgets.shinyMode) return; Shiny.onInputChange(map.id+'_draw_deletestart', true); }); - map.on(L.Draw.Event.DELETESTOP, function (e) { + map.on(L.Draw.Event.DELETESTOP, function () { if (!HTMLWidgets.shinyMode) return; Shiny.onInputChange(map.id+'_draw_deletestop', true); }); diff --git a/inst/htmlwidgets/bindings/lfx-gps-bindings.js b/inst/htmlwidgets/bindings/lfx-gps-bindings.js index f732fc90..a514421f 100644 --- a/inst/htmlwidgets/bindings/lfx-gps-bindings.js +++ b/inst/htmlwidgets/bindings/lfx-gps-bindings.js @@ -17,7 +17,7 @@ LeafletWidget.methods.addControlGPS = function(options) { 'radius': e.marker._radius }); }); - map.gpscontrol.on('gps:disabled', function(e){ + map.gpscontrol.on('gps:disabled', function(){ // Shiny stuff if (!HTMLWidgets.shinyMode) return; Shiny.onInputChange(map.id+'_gps_disabled',{}); diff --git a/inst/htmlwidgets/bindings/lfx-omnivore-bindings.js b/inst/htmlwidgets/bindings/lfx-omnivore-bindings.js index fffb8763..3eb9d55b 100644 --- a/inst/htmlwidgets/bindings/lfx-omnivore-bindings.js +++ b/inst/htmlwidgets/bindings/lfx-omnivore-bindings.js @@ -1,4 +1,4 @@ -/* global LeafletWidget, $, L, topojson, csv2geojson, toGeoJSON */ +/* global LeafletWidget, $, L, DOMParser, topojson, csv2geojson, toGeoJSON */ // parse an XML LeafletWidget.utils.parseXML = function(str) { diff --git a/inst/htmlwidgets/bindings/lfx-pulse-icon-bindings.js b/inst/htmlwidgets/bindings/lfx-pulse-icon-bindings.js index c19cc880..102d3cbd 100644 --- a/inst/htmlwidgets/bindings/lfx-pulse-icon-bindings.js +++ b/inst/htmlwidgets/bindings/lfx-pulse-icon-bindings.js @@ -4,9 +4,9 @@ LeafletWidget.methods.addPulseMarkers = function( lat, lng, icon, layerId, group, options, popup, popupOptions, clusterOptions, clusterId, label, labelOptions) { (function(){ - var icondf; - var getIcon; + let icondf; + let getIcon; if (icon) { // This cbinds the icon URLs and any other icon options; they're all diff --git a/inst/htmlwidgets/bindings/lfx-search-bindings.js b/inst/htmlwidgets/bindings/lfx-search-bindings.js index 048dc088..e63dbb85 100644 --- a/inst/htmlwidgets/bindings/lfx-search-bindings.js +++ b/inst/htmlwidgets/bindings/lfx-search-bindings.js @@ -1,4 +1,4 @@ -/* global $, LeafletWidget, L, Shiny, HTMLWidgets, google */ +/* global $, LeafletWidget, L, Shiny, HTMLWidgets, google, document */ // helper function to conver JS event to Shiny Event function eventToShiny(e) { @@ -66,7 +66,7 @@ LeafletWidget.methods.removeSearchOSM = function() { map.searchControlOSM.remove(map); delete map.searchControlOSM; } - var revsear = document.getElementById('reverseSearchOSM') + var revsear = document.getElementById('reverseSearchOSM'); if (revsear) { revsear.remove(); map.off('click', clickOSMEventHandler); @@ -106,8 +106,8 @@ LeafletWidget.methods.addReverseSearchOSM = function(options, group) { $.ajax({url: query, dataType: 'json'}).done(function(result){ // Check if the response contains an error - if (result.error && result.error === "Unable to geocode") { - displayControl.innerHTML = "Unable to geocode"; + if (result.error && result.error === 'Unable to geocode') { + displayControl.innerHTML = 'Unable to geocode'; return; } @@ -154,7 +154,7 @@ LeafletWidget.methods.addReverseSearchOSM = function(options, group) { if(!$.isEmptyObject(tmp) && tmp.length >= 0) { if(!$.isEmptyObject(marker)) { - marker.on('mouseover', function(e){ + marker.on('mouseover', function(){ if(!$.isEmptyObject(rect)) { rect.setStyle({fillOpacity: 0.5, opacity: 0.8, weight: 5}); rect.bringToFront(); @@ -164,7 +164,7 @@ LeafletWidget.methods.addReverseSearchOSM = function(options, group) { feature.bringToFront(); } }); - marker.on('mouseout', function(e){ + marker.on('mouseout', function(){ if(!$.isEmptyObject(rect)) { rect.setStyle({fillOpacity: 0.2, opacity: 0.5, weight: 2}); rect.bringToBack(); @@ -189,7 +189,7 @@ LeafletWidget.methods.addReverseSearchOSM = function(options, group) { } }); - } + }; map.on('click', clickOSMEventHandler); @@ -278,7 +278,7 @@ LeafletWidget.methods.removeSearchGoogle = function() { map.searchControlGoogle.remove(map); delete map.searchControlGoogle; } - var revsear = document.getElementById('reverseSearchGoogle') + var revsear = document.getElementById('reverseSearchGoogle'); if (revsear) { revsear.remove(); map.off('click', clickGOOEventHandler); @@ -415,9 +415,9 @@ LeafletWidget.methods.addReverseSearchGoogle = function(options, group) { } } ); - } + }; - map.on('click', clickGOOEventHandler) + map.on('click', clickGOOEventHandler); }).call(this); }; diff --git a/inst/htmlwidgets/bindings/lfx-wms-legend-bindings.js b/inst/htmlwidgets/bindings/lfx-wms-legend-bindings.js index 82c01518..09cec05b 100644 --- a/inst/htmlwidgets/bindings/lfx-wms-legend-bindings.js +++ b/inst/htmlwidgets/bindings/lfx-wms-legend-bindings.js @@ -1,12 +1,12 @@ /* global LeafletWidget, L */ LeafletWidget.methods.addWMSLegend1 = function(options) { (function(){ - var map = this; - var wmsLegendControl = new L.Control.WMSLegend(options.options); - if (options.layerId) { - map.controls.add(wmsLegendControl, options.layerId); - } else { - map.controls.add(wmsLegendControl); - } + var map = this; + var wmsLegendControl = new L.Control.WMSLegend(options.options); + if (options.layerId) { + map.controls.add(wmsLegendControl, options.layerId); + } else { + map.controls.add(wmsLegendControl); + } }).call(this); }; diff --git a/inst/htmlwidgets/build/lfx-bouncemarker/lfx-bouncemarker-bindings.js b/inst/htmlwidgets/build/lfx-bouncemarker/lfx-bouncemarker-bindings.js index 44f0ea85..985cf69b 100644 --- a/inst/htmlwidgets/build/lfx-bouncemarker/lfx-bouncemarker-bindings.js +++ b/inst/htmlwidgets/build/lfx-bouncemarker/lfx-bouncemarker-bindings.js @@ -1,2 +1,2 @@ -(()=>{function n(n){return n instanceof Array?n:[n]}function o(o){return o?void 0===o.index?o:(o.data=n(o.data),o.index=n(o.index),$.map(o.index,(function(n,e){return o.data[n]}))):o}LeafletWidget.methods.addBounceMarkers=function(n,e,i,t,c,a,r,d,h,l,s,p,u,w){(function(){let f,g;if(i&&(i.iconUrl=o(i.iconUrl),i.iconRetinaUrl=o(i.iconRetinaUrl),i.shadowUrl=o(i.shadowUrl),i.shadowRetinaUrl=o(i.shadowRetinaUrl),f=(new LeafletWidget.DataFrame).cbind(i),g=function(n){let o=f.get(n);return o.iconUrl?(o.iconWidth&&(o.iconSize=[o.iconWidth,o.iconHeight]),o.shadowWidth&&(o.shadowSize=[o.shadowWidth,o.shadowHeight]),o.iconAnchorX&&(o.iconAnchor=[o.iconAnchorX,o.iconAnchorY]),o.shadowAnchorX&&(o.shadowAnchor=[o.shadowAnchorX,o.shadowAnchorY]),o.popupAnchorX&&(o.popupAnchor=[o.popupAnchorX,o.popupAnchorY]),new L.Icon(o)):new L.Icon.Default}),!$.isEmptyObject(n)&&!$.isEmptyObject(e)||$.isNumeric(n)&&$.isNumeric(e)){var A=(new LeafletWidget.DataFrame).col("lat",n).col("lng",e).col("layerId",t).col("group",r).col("popup",h).col("popupOptions",l).col("label",u).col("labelOptions",w).cbind(d);i&&(f.effectiveLength=A.nrow()),LeafletWidget.methods.addGenericMarkers(this,A,r,s,p,((n,o)=>{var e=n.get(o);return i&&(e.icon=g(o)),e.bounceOnAdd=!0,e.bounceOnAddOptions={duration:c,height:a},L.marker([n.get(o,"lat"),n.get(o,"lng")],e)}))}}).call(this)}})(); +(()=>{function n(n){return n instanceof Array?n:[n]}function o(o){return o?void 0===o.index?o:(o.data=n(o.data),o.index=n(o.index),$.map(o.index,(function(n,e){return o.data[n]}))):o}LeafletWidget.methods.addBounceMarkers=function(n,e,i,t,c,a,r,d,h,l,s,u,p,w){(function(){var f,g;if(i&&(i.iconUrl=o(i.iconUrl),i.iconRetinaUrl=o(i.iconRetinaUrl),i.shadowUrl=o(i.shadowUrl),i.shadowRetinaUrl=o(i.shadowRetinaUrl),f=(new LeafletWidget.DataFrame).cbind(i),g=function(n){var o=f.get(n);return o.iconUrl?(o.iconWidth&&(o.iconSize=[o.iconWidth,o.iconHeight]),o.shadowWidth&&(o.shadowSize=[o.shadowWidth,o.shadowHeight]),o.iconAnchorX&&(o.iconAnchor=[o.iconAnchorX,o.iconAnchorY]),o.shadowAnchorX&&(o.shadowAnchor=[o.shadowAnchorX,o.shadowAnchorY]),o.popupAnchorX&&(o.popupAnchor=[o.popupAnchorX,o.popupAnchorY]),new L.Icon(o)):new L.Icon.Default}),!$.isEmptyObject(n)&&!$.isEmptyObject(e)||$.isNumeric(n)&&$.isNumeric(e)){var A=(new LeafletWidget.DataFrame).col("lat",n).col("lng",e).col("layerId",t).col("group",r).col("popup",h).col("popupOptions",l).col("label",p).col("labelOptions",w).cbind(d);i&&(f.effectiveLength=A.nrow()),LeafletWidget.methods.addGenericMarkers(this,A,r,s,u,(function(n,o){var e=n.get(o);return i&&(e.icon=g(o)),e.bounceOnAdd=!0,e.bounceOnAddOptions={duration:c,height:a},L.marker([n.get(o,"lat"),n.get(o,"lng")],e)}))}}).call(this)}})(); //# sourceMappingURL=lfx-bouncemarker-bindings.js.map \ No newline at end of file diff --git a/inst/htmlwidgets/build/lfx-bouncemarker/lfx-bouncemarker-bindings.js.map b/inst/htmlwidgets/build/lfx-bouncemarker/lfx-bouncemarker-bindings.js.map index 079bf359..b595d68a 100644 --- a/inst/htmlwidgets/build/lfx-bouncemarker/lfx-bouncemarker-bindings.js.map +++ b/inst/htmlwidgets/build/lfx-bouncemarker/lfx-bouncemarker-bindings.js.map @@ -1 +1 @@ -{"version":3,"file":"lfx-bouncemarker-bindings.js","mappings":"MAEA,SAASA,EAAQC,GACf,OAAIA,aAAiBC,MACZD,EAEA,CAACA,EACZ,CACA,SAASE,EAAcC,GACrB,OAAKA,OAGyB,IAAnBA,EAAa,MACfA,GAGTA,EAAQC,KAAOL,EAAQI,EAAQC,MAC/BD,EAAQE,MAAQN,EAAQI,EAAQE,OAEzBC,EAAEC,IAAIJ,EAAQE,OAAO,SAASG,EAAGC,GACtC,OAAON,EAAQC,KAAKI,EACtB,KAXSL,CAYX,CAGAO,cAAcC,QAAQC,iBAAmB,SACvCC,EAAKC,EAAKC,EAAMC,EAASC,EAAUC,EAAQC,EAAOC,EAClDC,EAAOC,EAAcC,EAAgBC,EAAWC,EAAOC,IACvD,WAEE,IAAIC,EACAC,EA0CJ,GAzCIb,IAEAA,EAAKc,QAAkB3B,EAAca,EAAKc,SAC1Cd,EAAKe,cAAkB5B,EAAca,EAAKe,eAC1Cf,EAAKgB,UAAkB7B,EAAca,EAAKgB,WAC1ChB,EAAKiB,gBAAkB9B,EAAca,EAAKiB,iBAI1CL,GAAS,IAAIjB,cAAcuB,WAAYC,MAAMnB,GAG7Ca,EAAU,SAASnB,GACjB,IAAI0B,EAAOR,EAAOS,IAAI3B,GACtB,OAAK0B,EAAKN,SAONM,EAAKE,YACPF,EAAKG,SAAW,CAACH,EAAKE,UAAWF,EAAKI,aAEpCJ,EAAKK,cACPL,EAAKM,WAAa,CAACN,EAAKK,YAAaL,EAAKO,eAExCP,EAAKQ,cACPR,EAAKS,WAAa,CAACT,EAAKQ,YAAaR,EAAKU,cAExCV,EAAKW,gBACPX,EAAKY,aAAe,CAACZ,EAAKW,cAAeX,EAAKa,gBAE5Cb,EAAKc,eACPd,EAAKe,YAAc,CAACf,EAAKc,aAAcd,EAAKgB,eAGvC,IAAIC,EAAEC,KAAKlB,IAtBT,IAAIiB,EAAEC,KAAKC,OAuBtB,IAGChD,EAAEiD,cAAc1C,KAAQP,EAAEiD,cAAczC,IAC1CR,EAAEkD,UAAU3C,IAAQP,EAAEkD,UAAU1C,GAAO,CAExC,IAAI2C,GAAK,IAAI/C,cAAcuB,WACxByB,IAAI,MAAO7C,GACX6C,IAAI,MAAO5C,GACX4C,IAAI,UAAW1C,GACf0C,IAAI,QAASvC,GACbuC,IAAI,QAASrC,GACbqC,IAAI,eAAgBpC,GACpBoC,IAAI,QAASjC,GACbiC,IAAI,eAAgBhC,GACpBQ,MAAMd,GAELL,IAAMY,EAAOgC,gBAAkBF,EAAGG,QAEtClD,cAAcC,QAAQkD,kBACpBC,KAAML,EAAItC,EAAOI,EAAgBC,GAAW,CAACiC,EAAIhD,KAC/C,IAAIW,EAAUqC,EAAGrB,IAAI3B,GAOrB,OANIM,IAAMK,EAAQL,KAAOa,EAAQnB,IACjCW,EAAQ2C,aAAc,EACtB3C,EAAQ4C,mBAAqB,CACzB/C,SAAUA,EACVC,OAAQA,GAELkC,EAAEa,OAAO,CAACR,EAAGrB,IAAI3B,EAAG,OAAQgD,EAAGrB,IAAI3B,EAAG,QAASW,EAAQ,GAEpE,CAGF,GAAE8C,KAAKJ,KACT,C","sources":["webpack://leaflet.extras/./inst/htmlwidgets/bindings/lfx-bouncemarker-bindings.js"],"sourcesContent":["/* global LeafletWidget, L */\r\n\r\nfunction asArray(value) {\r\n if (value instanceof Array)\r\n return value;\r\n else\r\n return [value];\r\n}\r\nfunction unpackStrings(iconset) {\r\n if (!iconset) {\r\n return iconset;\r\n }\r\n if (typeof(iconset.index) === \"undefined\") {\r\n return iconset;\r\n }\r\n\r\n iconset.data = asArray(iconset.data);\r\n iconset.index = asArray(iconset.index);\r\n\r\n return $.map(iconset.index, function(e, i) {\r\n return iconset.data[e];\r\n });\r\n}\r\n\r\n\r\nLeafletWidget.methods.addBounceMarkers = function(\r\n lat, lng, icon, layerId, duration, height, group, options,\r\n popup, popupOptions, clusterOptions, clusterId, label, labelOptions) {\r\n (function() {\r\n\r\n let icondf;\r\n let getIcon;\r\n if (icon) {\r\n // Unpack icons\r\n icon.iconUrl = unpackStrings(icon.iconUrl);\r\n icon.iconRetinaUrl = unpackStrings(icon.iconRetinaUrl);\r\n icon.shadowUrl = unpackStrings(icon.shadowUrl);\r\n icon.shadowRetinaUrl = unpackStrings(icon.shadowRetinaUrl);\r\n\r\n // This cbinds the icon URLs and any other icon options; they're all\r\n // present on the icon object.\r\n icondf = new LeafletWidget.DataFrame().cbind(icon);\r\n\r\n // Constructs an icon from a specified row of the icon dataframe.\r\n getIcon = function(i) {\r\n let opts = icondf.get(i);\r\n if (!opts.iconUrl) {\r\n return new L.Icon.Default();\r\n }\r\n\r\n // Composite options (like points or sizes) are passed from R with each\r\n // individual component as its own option. We need to combine them now\r\n // into their composite form.\r\n if (opts.iconWidth) {\r\n opts.iconSize = [opts.iconWidth, opts.iconHeight];\r\n }\r\n if (opts.shadowWidth) {\r\n opts.shadowSize = [opts.shadowWidth, opts.shadowHeight];\r\n }\r\n if (opts.iconAnchorX) {\r\n opts.iconAnchor = [opts.iconAnchorX, opts.iconAnchorY];\r\n }\r\n if (opts.shadowAnchorX) {\r\n opts.shadowAnchor = [opts.shadowAnchorX, opts.shadowAnchorY];\r\n }\r\n if (opts.popupAnchorX) {\r\n opts.popupAnchor = [opts.popupAnchorX, opts.popupAnchorY];\r\n }\r\n\r\n return new L.Icon(opts);\r\n };\r\n }\r\n\r\n if(!($.isEmptyObject(lat) || $.isEmptyObject(lng)) ||\r\n ($.isNumeric(lat) && $.isNumeric(lng))) {\r\n\r\n var df = new LeafletWidget.DataFrame()\r\n .col('lat', lat)\r\n .col('lng', lng)\r\n .col('layerId', layerId)\r\n .col('group', group)\r\n .col('popup', popup)\r\n .col('popupOptions', popupOptions)\r\n .col('label', label)\r\n .col('labelOptions', labelOptions)\r\n .cbind(options);\r\n\r\n if (icon) icondf.effectiveLength = df.nrow();\r\n\r\n LeafletWidget.methods.addGenericMarkers(\r\n this, df, group, clusterOptions, clusterId, (df, i) => {\r\n var options = df.get(i);\r\n if (icon) options.icon = getIcon(i);\r\n options.bounceOnAdd = true;\r\n options.bounceOnAddOptions = {\r\n duration: duration,\r\n height: height\r\n };\r\n return L.marker([df.get(i, 'lat'), df.get(i, 'lng')], options);\r\n });\r\n }\r\n\r\n }\r\n ).call(this);\r\n};\r\n"],"names":["asArray","value","Array","unpackStrings","iconset","data","index","$","map","e","i","LeafletWidget","methods","addBounceMarkers","lat","lng","icon","layerId","duration","height","group","options","popup","popupOptions","clusterOptions","clusterId","label","labelOptions","icondf","getIcon","iconUrl","iconRetinaUrl","shadowUrl","shadowRetinaUrl","DataFrame","cbind","opts","get","iconWidth","iconSize","iconHeight","shadowWidth","shadowSize","shadowHeight","iconAnchorX","iconAnchor","iconAnchorY","shadowAnchorX","shadowAnchor","shadowAnchorY","popupAnchorX","popupAnchor","popupAnchorY","L","Icon","Default","isEmptyObject","isNumeric","df","col","effectiveLength","nrow","addGenericMarkers","this","bounceOnAdd","bounceOnAddOptions","marker","call"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"lfx-bouncemarker-bindings.js","mappings":"MAEA,SAASA,EAAQC,GACf,OAAIA,aAAiBC,MACZD,EAEA,CAACA,EACZ,CACA,SAASE,EAAcC,GACrB,OAAKA,OAGyB,IAAnBA,EAAa,MACfA,GAGTA,EAAQC,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,GACbuC,IAAI,QAASrC,GACbqC,IAAI,eAAgBpC,GACpBoC,IAAI,QAASjC,GACbiC,IAAI,eAAgBhC,GACpBQ,MAAMd,GAELL,IAAMY,EAAOgC,gBAAkBF,EAAGG,QAEtClD,cAAcC,QAAQkD,kBACpBC,KAAML,EAAItC,EAAOI,EAAgBC,GAAW,SAASiC,EAAIhD,GACvD,IAAIW,EAAUqC,EAAGrB,IAAI3B,GAOrB,OANIM,IAAMK,EAAQL,KAAOa,EAAQnB,IACjCW,EAAQ2C,aAAc,EACtB3C,EAAQ4C,mBAAqB,CAC3B/C,SAAUA,EACVC,OAAQA,GAEHkC,EAAEa,OAAO,CAACR,EAAGrB,IAAI3B,EAAG,OAAQgD,EAAGrB,IAAI3B,EAAG,QAASW,EACxD,GACJ,CAGF,GAAE8C,KAAKJ,KACT,C","sources":["webpack://leaflet.extras/./inst/htmlwidgets/bindings/lfx-bouncemarker-bindings.js"],"sourcesContent":["/* global LeafletWidget, L, $ */\r\n\r\nfunction asArray(value) {\r\n if (value instanceof Array)\r\n return value;\r\n else\r\n return [value];\r\n}\r\nfunction unpackStrings(iconset) {\r\n if (!iconset) {\r\n return iconset;\r\n }\r\n if (typeof(iconset.index) === 'undefined') {\r\n return iconset;\r\n }\r\n\r\n iconset.data = asArray(iconset.data);\r\n iconset.index = asArray(iconset.index);\r\n\r\n return $.map(iconset.index, function(e, i) {\r\n return iconset.data[e];\r\n });\r\n}\r\n\r\n\r\nLeafletWidget.methods.addBounceMarkers = function(\r\n lat, lng, icon, layerId, duration, height, group, options,\r\n popup, popupOptions, clusterOptions, clusterId, label, labelOptions) {\r\n (function() {\r\n\r\n var icondf;\r\n var getIcon;\r\n\r\n if (icon) {\r\n // Unpack icons\r\n icon.iconUrl = unpackStrings(icon.iconUrl);\r\n icon.iconRetinaUrl = unpackStrings(icon.iconRetinaUrl);\r\n icon.shadowUrl = unpackStrings(icon.shadowUrl);\r\n icon.shadowRetinaUrl = unpackStrings(icon.shadowRetinaUrl);\r\n\r\n // This cbinds the icon URLs and any other icon options; they're all\r\n // present on the icon object.\r\n icondf = new LeafletWidget.DataFrame().cbind(icon);\r\n\r\n // Constructs an icon from a specified row of the icon dataframe.\r\n getIcon = function(i) {\r\n var opts = icondf.get(i);\r\n if (!opts.iconUrl) {\r\n return new L.Icon.Default();\r\n }\r\n\r\n // Composite options (like points or sizes) are passed from R with each\r\n // individual component as its own option. We need to combine them now\r\n // into their composite form.\r\n if (opts.iconWidth) {\r\n opts.iconSize = [opts.iconWidth, opts.iconHeight];\r\n }\r\n if (opts.shadowWidth) {\r\n opts.shadowSize = [opts.shadowWidth, opts.shadowHeight];\r\n }\r\n if (opts.iconAnchorX) {\r\n opts.iconAnchor = [opts.iconAnchorX, opts.iconAnchorY];\r\n }\r\n if (opts.shadowAnchorX) {\r\n opts.shadowAnchor = [opts.shadowAnchorX, opts.shadowAnchorY];\r\n }\r\n if (opts.popupAnchorX) {\r\n opts.popupAnchor = [opts.popupAnchorX, opts.popupAnchorY];\r\n }\r\n\r\n return new L.Icon(opts);\r\n };\r\n }\r\n\r\n if(!($.isEmptyObject(lat) || $.isEmptyObject(lng)) ||\r\n ($.isNumeric(lat) && $.isNumeric(lng))) {\r\n\r\n var df = new LeafletWidget.DataFrame()\r\n .col('lat', lat)\r\n .col('lng', lng)\r\n .col('layerId', layerId)\r\n .col('group', group)\r\n .col('popup', popup)\r\n .col('popupOptions', popupOptions)\r\n .col('label', label)\r\n .col('labelOptions', labelOptions)\r\n .cbind(options);\r\n\r\n if (icon) icondf.effectiveLength = df.nrow();\r\n\r\n LeafletWidget.methods.addGenericMarkers(\r\n this, df, group, clusterOptions, clusterId, function(df, i) {\r\n var options = df.get(i);\r\n if (icon) options.icon = getIcon(i);\r\n options.bounceOnAdd = true;\r\n options.bounceOnAddOptions = {\r\n duration: duration,\r\n height: height\r\n };\r\n return L.marker([df.get(i, 'lat'), df.get(i, 'lng')], options);\r\n });\r\n }\r\n\r\n }\r\n ).call(this);\r\n};\r\n"],"names":["asArray","value","Array","unpackStrings","iconset","data","index","$","map","e","i","LeafletWidget","methods","addBounceMarkers","lat","lng","icon","layerId","duration","height","group","options","popup","popupOptions","clusterOptions","clusterId","label","labelOptions","icondf","getIcon","iconUrl","iconRetinaUrl","shadowUrl","shadowRetinaUrl","DataFrame","cbind","opts","get","iconWidth","iconSize","iconHeight","shadowWidth","shadowSize","shadowHeight","iconAnchorX","iconAnchor","iconAnchorY","shadowAnchorX","shadowAnchor","shadowAnchorY","popupAnchorX","popupAnchor","popupAnchorY","L","Icon","Default","isEmptyObject","isNumeric","df","col","effectiveLength","nrow","addGenericMarkers","this","bounceOnAdd","bounceOnAddOptions","marker","call"],"sourceRoot":""} \ No newline at end of file diff --git a/inst/htmlwidgets/build/lfx-draw/lfx-draw-bindings.js b/inst/htmlwidgets/build/lfx-draw/lfx-draw-bindings.js index b7967c3b..22b71d47 100644 --- a/inst/htmlwidgets/build/lfx-draw/lfx-draw-bindings.js +++ b/inst/htmlwidgets/build/lfx-draw/lfx-draw-bindings.js @@ -1,2 +1,2 @@ -LeafletWidget.methods.addDrawToolbar=function(e,a,r){(function(){var t,o=this;if(o.drawToolbar&&(o.drawToolbar.remove(o),delete o.drawToolbar),e){if(!(t=o.layerManager.getLayer("geojson",e)))throw"GeoJSON layer with ID "+e+" not Found";o._editableGeoJSONLayerId=e}else a||(a="editableFeatureGroup"),t=o.layerManager.getLayerGroup(a,!0),o._editableFeatureGroupName=a;if(r&&r.draw&&r.draw.marker&&r.draw.marker.markerIcon&&r.draw.marker.markerIconFunction&&(r.draw.marker.icon=r.draw.marker.markerIconFunction(r.draw.marker.markerIcon)),!$.isEmptyObject(r.edit)){var n={};r.edit.remove||(n.remove=!1),r.edit.edit?$.isEmptyObject(r.edit.selectedPathOptions)||(n.edit={},n.edit.selectedPathOptions=r.edit.selectedPathOptions):n.edit=!1,$.isEmptyObject(r.edit.poly)||(n.poly=r.edit.poly),n.featureGroup=t,r.edit=n}if(r&&r.toolbar){var d=r.toolbar,i=L.drawLocal.draw.toolbar;L.drawLocal.draw.toolbar.buttons={...i.buttons,...d.buttons},L.drawLocal.draw.toolbar.actions={...i.actions,...d.actions},L.drawLocal.draw.toolbar.finish={...i.finish,...d.finish},L.drawLocal.draw.toolbar.undo={...i.undo,...d.undo}}if(r&&r.handlers){var l=r.handlers,s=L.drawLocal.draw.handlers;L.drawLocal.draw.handlers.circle={...s.circle,...l.circle},L.drawLocal.draw.handlers.circlemarker={...s.circlemarker,...l.circlemarker},L.drawLocal.draw.handlers.marker={...s.marker,...l.marker},L.drawLocal.draw.handlers.polygon={...s.polygon,...l.polygon},L.drawLocal.draw.handlers.polyline={...s.polyline,...l.polyline},L.drawLocal.draw.handlers.rectangle={...s.rectangle,...l.rectangle}}o.drawToolbar=new L.Control.Draw(r),o.drawToolbar.addTo(o),o.on(L.Draw.Event.DRAWSTART,(function(e){HTMLWidgets.shinyMode&&Shiny.onInputChange(o.id+"_draw_start",{feature_type:e.layerType,nonce:Math.random()})})),o.on(L.Draw.Event.DRAWSTOP,(function(e){HTMLWidgets.shinyMode&&Shiny.onInputChange(o.id+"_draw_stop",{feature_type:e.layerType,nonce:Math.random()})})),o.on(L.Draw.Event.CREATED,(function(e){r.draw.singleFeature&&t.getLayers().length>0&&t.clearLayers();var a=e.layer;t.addLayer(a);var n=L.stamp(a);a.feature={type:"Feature",properties:{_leaflet_id:n,feature_type:e.layerType}},"function"==typeof a.getRadius&&(a.feature.properties.radius=a.getRadius()),HTMLWidgets.shinyMode&&(Shiny.onInputChange(o.id+"_draw_new_feature",a.toGeoJSON()),Shiny.onInputChange(o.id+"_draw_all_features",t.toGeoJSON()))})),o.on(L.Draw.Event.EDITSTART,(function(e){HTMLWidgets.shinyMode&&Shiny.onInputChange(o.id+"_draw_editstart",!0)})),o.on(L.Draw.Event.EDITSTOP,(function(e){HTMLWidgets.shinyMode&&Shiny.onInputChange(o.id+"_draw_editstop",!0)})),o.on(L.Draw.Event.EDITED,(function(e){var a=e.layers;a.eachLayer((function(e){var a=L.stamp(e);e.feature||(e.feature={type:"Feature"}),e.feature.properties||(e.feature.properties={}),e.feature.properties._leaflet_id=a,e.feature.properties.layerId=e.options.layerId,"function"==typeof e.getRadius&&(e.feature.properties.radius=e.getRadius())})),HTMLWidgets.shinyMode&&(Shiny.onInputChange(o.id+"_draw_edited_features",a.toGeoJSON()),Shiny.onInputChange(o.id+"_draw_all_features",t.toGeoJSON()))})),o.on(L.Draw.Event.DELETESTART,(function(e){HTMLWidgets.shinyMode&&Shiny.onInputChange(o.id+"_draw_deletestart",!0)})),o.on(L.Draw.Event.DELETESTOP,(function(e){HTMLWidgets.shinyMode&&Shiny.onInputChange(o.id+"_draw_deletestop",!0)})),o.on(L.Draw.Event.DELETED,(function(e){var a=e.layers;a.eachLayer((function(e){var a=L.stamp(e);e.feature||(e.feature={type:"Feature"}),e.feature.properties||(e.feature.properties={}),e.feature.properties._leaflet_id=a,e.feature.properties.layerId=e.options.layerId,"function"==typeof e.getRadius&&(e.feature.properties.radius=e.getRadius())})),HTMLWidgets.shinyMode&&(Shiny.onInputChange(o.id+"_draw_deleted_features",a.toGeoJSON()),Shiny.onInputChange(o.id+"_draw_all_features",t.toGeoJSON()))}))}).call(this)},LeafletWidget.methods.removeDrawToolbar=function(e){(function(){var a=this;a.drawToolbar&&(a.drawToolbar.remove(a),delete a.drawToolbar),a._editableFeatureGroupName&&e&&a.layerManager.getLayerGroup(a._editableFeatureGroupName,!1).clearLayers(),a._editableFeatureGroupName=null,a._editableGeoJSONLayerId&&e&&a.layerManager.removeLayer("geojson",a._editableGeoJSONLayerId),a._editableGeoJSONLayerId=null}).call(this)},LeafletWidget.methods.getDrawnItems=function(){var e,a=this;return a._editableGeoJSONLayerId?e=a.layerManager.getLayer("geojson",a._editableGeoJSONLayerId):a._editableFeatureGroupName&&(e=a.layerManager.getLayerGroup(a._editableFeatureGroupName,!1)),e?e.toGeoJSON():null}; +LeafletWidget.methods.addDrawToolbar=function(e,a,r){(function(){var t,o=this;if(o.drawToolbar&&(o.drawToolbar.remove(o),delete o.drawToolbar),e){if(!(t=o.layerManager.getLayer("geojson",e)))throw"GeoJSON layer with ID "+e+" not Found";o._editableGeoJSONLayerId=e}else a||(a="editableFeatureGroup"),t=o.layerManager.getLayerGroup(a,!0),o._editableFeatureGroupName=a;if(r&&r.draw&&r.draw.marker&&r.draw.marker.markerIcon&&r.draw.marker.markerIconFunction&&(r.draw.marker.icon=r.draw.marker.markerIconFunction(r.draw.marker.markerIcon)),!$.isEmptyObject(r.edit)){var n={};r.edit.remove||(n.remove=!1),r.edit.edit?$.isEmptyObject(r.edit.selectedPathOptions)||(n.edit={},n.edit.selectedPathOptions=r.edit.selectedPathOptions):n.edit=!1,$.isEmptyObject(r.edit.poly)||(n.poly=r.edit.poly),n.featureGroup=t,r.edit=n}if(r&&r.toolbar){var d=r.toolbar,i=L.drawLocal.draw.toolbar;L.drawLocal.draw.toolbar.buttons=Object.assign({},i.buttons,d.buttons),L.drawLocal.draw.toolbar.actions=Object.assign({},i.actions,d.actions),L.drawLocal.draw.toolbar.finish=Object.assign({},i.finish,d.finish),L.drawLocal.draw.toolbar.undo=Object.assign({},i.undo,d.undo)}if(r&&r.handlers){var l=r.handlers,s=L.drawLocal.draw.handlers;L.drawLocal.draw.handlers.circle=Object.assign({},s.circle,l.circle),L.drawLocal.draw.handlers.circlemarker=Object.assign({},s.circlemarker,l.circlemarker),L.drawLocal.draw.handlers.marker=Object.assign({},s.marker,l.marker),L.drawLocal.draw.handlers.polygon=Object.assign({},s.polygon,l.polygon),L.drawLocal.draw.handlers.polyline=Object.assign({},s.polyline,l.polyline),L.drawLocal.draw.handlers.rectangle=Object.assign({},s.rectangle,l.rectangle)}o.drawToolbar=new L.Control.Draw(r),o.drawToolbar.addTo(o),o.on(L.Draw.Event.DRAWSTART,(function(e){HTMLWidgets.shinyMode&&Shiny.onInputChange(o.id+"_draw_start",{feature_type:e.layerType,nonce:Math.random()})})),o.on(L.Draw.Event.DRAWSTOP,(function(e){HTMLWidgets.shinyMode&&Shiny.onInputChange(o.id+"_draw_stop",{feature_type:e.layerType,nonce:Math.random()})})),o.on(L.Draw.Event.CREATED,(function(e){r.draw.singleFeature&&t.getLayers().length>0&&t.clearLayers();var a=e.layer;t.addLayer(a);var n=L.stamp(a);a.feature={type:"Feature",properties:{_leaflet_id:n,feature_type:e.layerType}},"function"==typeof a.getRadius&&(a.feature.properties.radius=a.getRadius()),HTMLWidgets.shinyMode&&(Shiny.onInputChange(o.id+"_draw_new_feature",a.toGeoJSON()),Shiny.onInputChange(o.id+"_draw_all_features",t.toGeoJSON()))})),o.on(L.Draw.Event.EDITSTART,(function(){HTMLWidgets.shinyMode&&Shiny.onInputChange(o.id+"_draw_editstart",!0)})),o.on(L.Draw.Event.EDITSTOP,(function(){HTMLWidgets.shinyMode&&Shiny.onInputChange(o.id+"_draw_editstop",!0)})),o.on(L.Draw.Event.EDITED,(function(e){var a=e.layers;a.eachLayer((function(e){var a=L.stamp(e);e.feature||(e.feature={type:"Feature"}),e.feature.properties||(e.feature.properties={}),e.feature.properties._leaflet_id=a,e.feature.properties.layerId=e.options.layerId,"function"==typeof e.getRadius&&(e.feature.properties.radius=e.getRadius())})),HTMLWidgets.shinyMode&&(Shiny.onInputChange(o.id+"_draw_edited_features",a.toGeoJSON()),Shiny.onInputChange(o.id+"_draw_all_features",t.toGeoJSON()))})),o.on(L.Draw.Event.DELETESTART,(function(){HTMLWidgets.shinyMode&&Shiny.onInputChange(o.id+"_draw_deletestart",!0)})),o.on(L.Draw.Event.DELETESTOP,(function(){HTMLWidgets.shinyMode&&Shiny.onInputChange(o.id+"_draw_deletestop",!0)})),o.on(L.Draw.Event.DELETED,(function(e){var a=e.layers;a.eachLayer((function(e){var a=L.stamp(e);e.feature||(e.feature={type:"Feature"}),e.feature.properties||(e.feature.properties={}),e.feature.properties._leaflet_id=a,e.feature.properties.layerId=e.options.layerId,"function"==typeof e.getRadius&&(e.feature.properties.radius=e.getRadius())})),HTMLWidgets.shinyMode&&(Shiny.onInputChange(o.id+"_draw_deleted_features",a.toGeoJSON()),Shiny.onInputChange(o.id+"_draw_all_features",t.toGeoJSON()))}))}).call(this)},LeafletWidget.methods.removeDrawToolbar=function(e){(function(){var a=this;a.drawToolbar&&(a.drawToolbar.remove(a),delete a.drawToolbar),a._editableFeatureGroupName&&e&&a.layerManager.getLayerGroup(a._editableFeatureGroupName,!1).clearLayers(),a._editableFeatureGroupName=null,a._editableGeoJSONLayerId&&e&&a.layerManager.removeLayer("geojson",a._editableGeoJSONLayerId),a._editableGeoJSONLayerId=null}).call(this)},LeafletWidget.methods.getDrawnItems=function(){var e,a=this;return a._editableGeoJSONLayerId?e=a.layerManager.getLayer("geojson",a._editableGeoJSONLayerId):a._editableFeatureGroupName&&(e=a.layerManager.getLayerGroup(a._editableFeatureGroupName,!1)),e?e.toGeoJSON():null}; //# sourceMappingURL=lfx-draw-bindings.js.map \ No newline at end of file diff --git a/inst/htmlwidgets/build/lfx-draw/lfx-draw-bindings.js.map b/inst/htmlwidgets/build/lfx-draw/lfx-draw-bindings.js.map index d8f5307d..00a49142 100644 --- a/inst/htmlwidgets/build/lfx-draw/lfx-draw-bindings.js.map +++ b/inst/htmlwidgets/build/lfx-draw/lfx-draw-bindings.js.map @@ -1 +1 @@ -{"version":3,"file":"lfx-draw-bindings.js","mappings":"AAEAA,cAAcC,QAAQC,eAAiB,SAASC,EAAeC,EAAaC,IAC1E,WAEE,IAWIC,EAXAC,EAAMC,KAaV,GAXGD,EAAIE,cACLF,EAAIE,YAAYC,OAAOH,UAChBA,EAAIE,aASVN,EAAe,CAGhB,KADAG,EAAuBC,EAAII,aAAaC,SAAS,UAAWT,IAK1D,KAAM,yBAAyBA,EAAc,aAH7CI,EAAIM,wBAA0BV,CAKlC,MAIMC,IACFA,EAAc,wBAEhBE,EAAuBC,EAAII,aAAaG,cAAcV,GAAa,GACnEG,EAAIQ,0BAA4BX,EAclC,GAVGC,GAAWA,EAAQW,MAAQX,EAAQW,KAAKC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AMI,QAAQE,WAAa,CAAC,GAE9BN,EAAMI,QAAQE,WAAWQ,YAAcZ,EACvCF,EAAMI,QAAQE,WAAWS,QAAUf,EAAM7D,QAAQ4E,QACnB,mBAApBf,EAAMK,YACdL,EAAMI,QAAQE,WAAWC,OAASP,EAAMK,YAE5C,IAEKnB,YAAYC,YACjBC,MAAMC,cAAchD,EAAIiD,GAAG,yBACzBsB,EAAOJ,aACTpB,MAAMC,cAAchD,EAAIiD,GAAG,qBACzBlD,EAAqBoE,aACzB,GAED,GAAEW,KAAK7E,KAEV,EAEAR,cAAcC,QAAQqF,kBAAoB,SAASC,IACjD,WAEE,IAAIhF,EAAMC,KAEPD,EAAIE,cACLF,EAAIE,YAAYC,OAAOH,UAChBA,EAAIE,aAEVF,EAAIQ,2BAA6BwE,GACfhF,EAAII,aAAaG,cAAcP,EAAIQ,2BAA2B,GACpEkD,cAEf1D,EAAIQ,0BAA4B,KAC7BR,EAAIM,yBAA2B0E,GAChChF,EAAII,aAAa6E,YAAY,UAAWjF,EAAIM,yBAE9CN,EAAIM,wBAA0B,IAC/B,GAAEwE,KAAK7E,KAEV,EAIAR,cAAcC,QAAQwF,cAAgB,WACpC,IAEI9D,EAFApB,EAAMC,KAQV,OALGD,EAAIM,wBACLc,EAAepB,EAAII,aAAaC,SAAS,UAAWL,EAAIM,yBAChDN,EAAIQ,4BACZY,EAAepB,EAAII,aAAaG,cAAcP,EAAIQ,2BAA2B,IAE5EY,EACMA,EAAa+C,YAEb,IAGX","sources":["webpack://leaflet.extras/./inst/htmlwidgets/bindings/lfx-draw-bindings.js"],"sourcesContent":["/* global LeafletWidget, $, L, Shiny, HTMLWidgets */\r\n\r\nLeafletWidget.methods.addDrawToolbar = function(targetLayerId, targetGroup, options) {\r\n (function(){\r\n\r\n var map = this;\r\n\r\n if(map.drawToolbar) {\r\n map.drawToolbar.remove(map);\r\n delete map.drawToolbar;\r\n }\r\n\r\n // FeatureGroup that will hold our drawn shapes/markers\r\n // This can be an existing GeoJSON layer whose features can be edited/deleted or new ones added.\r\n // OR an existing FeatureGroup whose features can be edited/deleted or new ones added.\r\n // OR a new FeatureGroup to hold drawn shapes.\r\n var editableFeatureGroup;\r\n\r\n if(targetLayerId) {\r\n // If we're given an existing GeoJSON layer find it and use it\r\n editableFeatureGroup = map.layerManager.getLayer('geojson', targetLayerId);\r\n if(editableFeatureGroup) {\r\n map._editableGeoJSONLayerId = targetLayerId;\r\n } else {\r\n // throw an error if we can't find the target GeoJSON layer\r\n throw 'GeoJSON layer with ID '+targetLayerId+' not Found';\r\n }\r\n } else {\r\n // If we're given an existing FeatureLayer use that.\r\n // In this case we don't throw an error if the specified FeatureGroup is not found,\r\n // we silently create a new one.\r\n if(!targetGroup) {\r\n targetGroup = 'editableFeatureGroup';\r\n }\r\n editableFeatureGroup = map.layerManager.getLayerGroup(targetGroup, true);\r\n map._editableFeatureGroupName = targetGroup;\r\n }\r\n\r\n // Create appropriate Marker Icon.\r\n if(options && options.draw && options.draw.marker) {\r\n if(options.draw.marker.markerIcon &&\r\n options.draw.marker.markerIconFunction) {\r\n options.draw.marker.icon =\r\n options.draw.marker.markerIconFunction(\r\n options.draw.marker.markerIcon);\r\n }\r\n }\r\n\r\n // create appropriate options\r\n if(!$.isEmptyObject(options.edit)) {\r\n var editOptions = {};\r\n if(!options.edit.remove) {\r\n editOptions.remove = false;\r\n }\r\n if(!options.edit.edit) {\r\n editOptions.edit = false;\r\n } else if(!$.isEmptyObject(options.edit.selectedPathOptions)) {\r\n editOptions.edit = {};\r\n editOptions.edit.selectedPathOptions =\r\n options.edit.selectedPathOptions;\r\n }\r\n\r\n if(!$.isEmptyObject(options.edit.poly)) {\r\n editOptions.poly = options.edit.poly;\r\n }\r\n\r\n editOptions.featureGroup = editableFeatureGroup;\r\n options.edit = editOptions;\r\n }\r\n\r\n // Set Toolbar / Handlers options if provided. Changes the default values.\r\n if (options && options.toolbar) {\r\n var rtool = options.toolbar;\r\n var tooldef = L.drawLocal.draw.toolbar;\r\n L.drawLocal.draw.toolbar.buttons = {\r\n ...tooldef.buttons,\r\n ...rtool.buttons\r\n };\r\n L.drawLocal.draw.toolbar.actions = {\r\n ...tooldef.actions,\r\n ...rtool.actions\r\n };\r\n L.drawLocal.draw.toolbar.finish = {\r\n ...tooldef.finish,\r\n ...rtool.finish\r\n };\r\n L.drawLocal.draw.toolbar.undo = {\r\n ...tooldef.undo,\r\n ...rtool.undo\r\n };\r\n }\r\n if (options && options.handlers) {\r\n var rhand = options.handlers;\r\n var handldef = L.drawLocal.draw.handlers;\r\n L.drawLocal.draw.handlers.circle = {\r\n ...handldef.circle,\r\n ...rhand.circle\r\n };\r\n L.drawLocal.draw.handlers.circlemarker = {\r\n ...handldef.circlemarker,\r\n ...rhand.circlemarker\r\n };\r\n L.drawLocal.draw.handlers.marker = {\r\n ...handldef.marker,\r\n ...rhand.marker\r\n };\r\n L.drawLocal.draw.handlers.polygon = {\r\n ...handldef.polygon,\r\n ...rhand.polygon\r\n };\r\n L.drawLocal.draw.handlers.polyline = {\r\n ...handldef.polyline,\r\n ...rhand.polyline\r\n };\r\n L.drawLocal.draw.handlers.rectangle = {\r\n ...handldef.rectangle,\r\n ...rhand.rectangle\r\n };\r\n }\r\n\r\n // Create new Drawing Control\r\n map.drawToolbar = new L.Control.Draw(options);\r\n map.drawToolbar.addTo(map);\r\n\r\n // Event Listeners\r\n map.on(L.Draw.Event.DRAWSTART, function(e) {\r\n if (!HTMLWidgets.shinyMode) return;\r\n Shiny.onInputChange(map.id+'_draw_start', {'feature_type': e.layerType, 'nonce': Math.random()});\r\n });\r\n\r\n map.on(L.Draw.Event.DRAWSTOP, function(e) {\r\n if (!HTMLWidgets.shinyMode) return;\r\n Shiny.onInputChange(map.id+'_draw_stop', {'feature_type': e.layerType,'nonce': Math.random()});\r\n });\r\n\r\n map.on(L.Draw.Event.CREATED, function (e) {\r\n if (options.draw.singleFeature){\r\n if (editableFeatureGroup.getLayers().length > 0) {\r\n editableFeatureGroup.clearLayers();\r\n }\r\n }\r\n\r\n var layer = e.layer;\r\n editableFeatureGroup.addLayer(layer);\r\n\r\n // assign a unique key to the newly created feature\r\n var featureId = L.stamp(layer);\r\n layer.feature = {\r\n 'type' : 'Feature',\r\n 'properties' : {\r\n '_leaflet_id' : featureId,\r\n 'feature_type' : e.layerType\r\n }\r\n };\r\n\r\n // circles are just Points and toGeoJSON won't store radius by default\r\n // so we store it inside the properties.\r\n if(typeof layer.getRadius === 'function') {\r\n layer.feature.properties.radius = layer.getRadius();\r\n }\r\n\r\n if (!HTMLWidgets.shinyMode) return;\r\n\r\n Shiny.onInputChange(map.id+'_draw_new_feature',\r\n layer.toGeoJSON());\r\n Shiny.onInputChange(map.id+'_draw_all_features',\r\n editableFeatureGroup.toGeoJSON());\r\n });\r\n\r\n map.on(L.Draw.Event.EDITSTART, function (e) {\r\n if (!HTMLWidgets.shinyMode) return;\r\n Shiny.onInputChange(map.id+'_draw_editstart', true);\r\n });\r\n map.on(L.Draw.Event.EDITSTOP, function (e) {\r\n if (!HTMLWidgets.shinyMode) return;\r\n Shiny.onInputChange(map.id+'_draw_editstop', true);\r\n });\r\n\r\n map.on(L.Draw.Event.EDITED, function (e) {\r\n var layers = e.layers;\r\n layers.eachLayer(function(layer){\r\n var featureId = L.stamp(layer);\r\n if(!layer.feature) {\r\n layer.feature = {'type' : 'Feature'};\r\n }\r\n if(!layer.feature.properties) {\r\n layer.feature.properties = {};\r\n }\r\n layer.feature.properties._leaflet_id = featureId;\r\n layer.feature.properties.layerId = layer.options.layerId;\r\n if(typeof layer.getRadius === 'function') {\r\n layer.feature.properties.radius = layer.getRadius();\r\n }\r\n });\r\n\r\n if (!HTMLWidgets.shinyMode) return;\r\n\r\n Shiny.onInputChange(map.id+'_draw_edited_features',\r\n layers.toGeoJSON());\r\n Shiny.onInputChange(map.id+'_draw_all_features',\r\n editableFeatureGroup.toGeoJSON());\r\n });\r\n\r\n map.on(L.Draw.Event.DELETESTART, function (e) {\r\n if (!HTMLWidgets.shinyMode) return;\r\n Shiny.onInputChange(map.id+'_draw_deletestart', true);\r\n });\r\n\r\n map.on(L.Draw.Event.DELETESTOP, function (e) {\r\n if (!HTMLWidgets.shinyMode) return;\r\n Shiny.onInputChange(map.id+'_draw_deletestop', true);\r\n });\r\n\r\n map.on(L.Draw.Event.DELETED, function (e) {\r\n var layers = e.layers;\r\n layers.eachLayer(function(layer){\r\n var featureId = L.stamp(layer);\r\n if(!layer.feature) {\r\n layer.feature = {'type' : 'Feature'};\r\n }\r\n if(!layer.feature.properties) {\r\n layer.feature.properties = {};\r\n }\r\n layer.feature.properties._leaflet_id = featureId;\r\n layer.feature.properties.layerId = layer.options.layerId;\r\n if(typeof layer.getRadius === 'function') {\r\n layer.feature.properties.radius = layer.getRadius();\r\n }\r\n });\r\n\r\n if (!HTMLWidgets.shinyMode) return;\r\n Shiny.onInputChange(map.id+'_draw_deleted_features',\r\n layers.toGeoJSON());\r\n Shiny.onInputChange(map.id+'_draw_all_features',\r\n editableFeatureGroup.toGeoJSON());\r\n });\r\n\r\n }).call(this);\r\n\r\n};\r\n\r\nLeafletWidget.methods.removeDrawToolbar = function(clearFeatures) {\r\n (function(){\r\n\r\n var map = this;\r\n\r\n if(map.drawToolbar) {\r\n map.drawToolbar.remove(map);\r\n delete map.drawToolbar;\r\n }\r\n if(map._editableFeatureGroupName && clearFeatures) {\r\n var featureGroup = map.layerManager.getLayerGroup(map._editableFeatureGroupName, false);\r\n featureGroup.clearLayers();\r\n }\r\n map._editableFeatureGroupName = null;\r\n if(map._editableGeoJSONLayerId && clearFeatures) {\r\n map.layerManager.removeLayer('geojson', map._editableGeoJSONLayerId);\r\n }\r\n map._editableGeoJSONLayerId = null;\r\n }).call(this);\r\n\r\n};\r\n\r\n\r\n// TODO - not used for now. Missing R-function..Is it working?\r\nLeafletWidget.methods.getDrawnItems = function() {\r\n var map = this;\r\n\r\n var featureGroup;\r\n if(map._editableGeoJSONLayerId) {\r\n featureGroup = map.layerManager.getLayer('geojson', map._editableGeoJSONLayerId);\r\n } else if(map._editableFeatureGroupName) {\r\n featureGroup = map.layerManager.getLayerGroup(map._editableFeatureGroupName, false);\r\n }\r\n if(featureGroup) {\r\n return featureGroup.toGeoJSON();\r\n } else {\r\n return null;\r\n }\r\n\r\n};\r\n"],"names":["LeafletWidget","methods","addDrawToolbar","targetLayerId","targetGroup","options","editableFeatureGroup","map","this","drawToolbar","remove","layerManager","getLayer","_editableGeoJSONLayerId","getLayerGroup","_editableFeatureGroupName","draw","marker","markerIcon","markerIconFunction","icon","$","isEmptyObject","edit","editOptions","selectedPathOptions","poly","featureGroup","toolbar","rtool","tooldef","L","drawLocal","buttons","actions","finish","undo","handlers","rhand","handldef","circle","circlemarker","polygon","polyline","rectangle","Control","Draw","addTo","on","Event","DRAWSTART","e","HTMLWidgets","shinyMode","Shiny","onInputChange","id","layerType","Math","random","DRAWSTOP","CREATED","singleFeature","getLayers","length","clearLayers","layer","addLayer","featureId","stamp","feature","getRadius","properties","radius","toGeoJSON","EDITSTART","EDITSTOP","EDITED","layers","eachLayer","_leaflet_id","layerId","DELETESTART","DELETESTOP","DELETED","call","removeDrawToolbar","clearFeatures","removeLayer","getDrawnItems"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"lfx-draw-bindings.js","mappings":"AAEAA,cAAcC,QAAQC,eAAiB,SAASC,EAAeC,EAAaC,IAC1E,WAEE,IAWIC,EAXAC,EAAMC,KAaV,GAXGD,EAAIE,cACLF,EAAIE,YAAYC,OAAOH,UAChBA,EAAIE,aASVN,EAAe,CAGhB,KADAG,EAAuBC,EAAII,aAAaC,SAAS,UAAWT,IAK1D,KAAM,yBAAyBA,EAAc,aAH7CI,EAAIM,wBAA0BV,CAKlC,MAIMC,IACFA,EAAc,wBAEhBE,EAAuBC,EAAII,aAAaG,cAAcV,GAAa,GACnEG,EAAIQ,0BAA4BX,EAclC,GAVGC,GAAWA,EAAQW,MAAQX,EAAQW,KAAKC,QACtCZ,EAAQW,KAAKC,OAAOC,YACrBb,EAAQW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A,EAAOC,WAAU,SAASb,GACxB,IAAIE,EAAYvC,EAAEwC,MAAMH,GACpBA,EAAMI,UACRJ,EAAMI,QAAU,CAAC,KAAS,YAExBJ,EAAMI,QAAQE,aAChBN,EAAMI,QAAQE,WAAa,CAAC,GAE9BN,EAAMI,QAAQE,WAAWQ,YAAcZ,EACvCF,EAAMI,QAAQE,WAAWS,QAAUf,EAAM/D,QAAQ8E,QACnB,mBAApBf,EAAMK,YACdL,EAAMI,QAAQE,WAAWC,OAASP,EAAMK,YAE5C,IAEKnB,YAAYC,YACjBC,MAAMC,cAAclD,EAAImD,GAAG,yBACzBsB,EAAOJ,aACTpB,MAAMC,cAAclD,EAAImD,GAAG,qBACzBpD,EAAqBsE,aACzB,GAED,GAAEW,KAAK/E,KAEV,EAEAR,cAAcC,QAAQuF,kBAAoB,SAASC,IACjD,WAEE,IAAIlF,EAAMC,KAEPD,EAAIE,cACLF,EAAIE,YAAYC,OAAOH,UAChBA,EAAIE,aAEVF,EAAIQ,2BAA6B0E,GACflF,EAAII,aAAaG,cAAcP,EAAIQ,2BAA2B,GACpEoD,cAEf5D,EAAIQ,0BAA4B,KAC7BR,EAAIM,yBAA2B4E,GAChClF,EAAII,aAAa+E,YAAY,UAAWnF,EAAIM,yBAE9CN,EAAIM,wBAA0B,IAC/B,GAAE0E,KAAK/E,KAEV,EAIAR,cAAcC,QAAQ0F,cAAgB,WACpC,IAEIhE,EAFApB,EAAMC,KAQV,OALGD,EAAIM,wBACLc,EAAepB,EAAII,aAAaC,SAAS,UAAWL,EAAIM,yBAChDN,EAAIQ,4BACZY,EAAepB,EAAII,aAAaG,cAAcP,EAAIQ,2BAA2B,IAE5EY,EACMA,EAAaiD,YAEb,IAGX","sources":["webpack://leaflet.extras/./inst/htmlwidgets/bindings/lfx-draw-bindings.js"],"sourcesContent":["/* global LeafletWidget, $, L, Shiny, HTMLWidgets */\r\n\r\nLeafletWidget.methods.addDrawToolbar = function(targetLayerId, targetGroup, options) {\r\n (function(){\r\n\r\n var map = this;\r\n\r\n if(map.drawToolbar) {\r\n map.drawToolbar.remove(map);\r\n delete map.drawToolbar;\r\n }\r\n\r\n // FeatureGroup that will hold our drawn shapes/markers\r\n // This can be an existing GeoJSON layer whose features can be edited/deleted or new ones added.\r\n // OR an existing FeatureGroup whose features can be edited/deleted or new ones added.\r\n // OR a new FeatureGroup to hold drawn shapes.\r\n var editableFeatureGroup;\r\n\r\n if(targetLayerId) {\r\n // If we're given an existing GeoJSON layer find it and use it\r\n editableFeatureGroup = map.layerManager.getLayer('geojson', targetLayerId);\r\n if(editableFeatureGroup) {\r\n map._editableGeoJSONLayerId = targetLayerId;\r\n } else {\r\n // throw an error if we can't find the target GeoJSON layer\r\n throw 'GeoJSON layer with ID '+targetLayerId+' not Found';\r\n }\r\n } else {\r\n // If we're given an existing FeatureLayer use that.\r\n // In this case we don't throw an error if the specified FeatureGroup is not found,\r\n // we silently create a new one.\r\n if(!targetGroup) {\r\n targetGroup = 'editableFeatureGroup';\r\n }\r\n editableFeatureGroup = map.layerManager.getLayerGroup(targetGroup, true);\r\n map._editableFeatureGroupName = targetGroup;\r\n }\r\n\r\n // Create appropriate Marker Icon.\r\n if(options && options.draw && options.draw.marker) {\r\n if(options.draw.marker.markerIcon &&\r\n options.draw.marker.markerIconFunction) {\r\n options.draw.marker.icon =\r\n options.draw.marker.markerIconFunction(\r\n options.draw.marker.markerIcon);\r\n }\r\n }\r\n\r\n // create appropriate options\r\n if(!$.isEmptyObject(options.edit)) {\r\n var editOptions = {};\r\n if(!options.edit.remove) {\r\n editOptions.remove = false;\r\n }\r\n if(!options.edit.edit) {\r\n editOptions.edit = false;\r\n } else if(!$.isEmptyObject(options.edit.selectedPathOptions)) {\r\n editOptions.edit = {};\r\n editOptions.edit.selectedPathOptions =\r\n options.edit.selectedPathOptions;\r\n }\r\n\r\n if(!$.isEmptyObject(options.edit.poly)) {\r\n editOptions.poly = options.edit.poly;\r\n }\r\n\r\n editOptions.featureGroup = editableFeatureGroup;\r\n options.edit = editOptions;\r\n }\r\n\r\n // Set Toolbar / Handlers options if provided. Changes the default values.\r\n if (options && options.toolbar) {\r\n var rtool = options.toolbar;\r\n var tooldef = L.drawLocal.draw.toolbar;\r\n L.drawLocal.draw.toolbar.buttons = Object.assign({}, tooldef.buttons, rtool.buttons);\r\n L.drawLocal.draw.toolbar.actions = Object.assign({}, tooldef.actions, rtool.actions);\r\n L.drawLocal.draw.toolbar.finish = Object.assign({}, tooldef.finish, rtool.finish);\r\n L.drawLocal.draw.toolbar.undo = Object.assign({}, tooldef.undo, rtool.undo);\r\n }\r\n if (options && options.handlers) {\r\n var rhand = options.handlers;\r\n var handldef = L.drawLocal.draw.handlers;\r\n L.drawLocal.draw.handlers.circle = Object.assign({}, handldef.circle, rhand.circle);\r\n L.drawLocal.draw.handlers.circlemarker = Object.assign({}, handldef.circlemarker, rhand.circlemarker);\r\n L.drawLocal.draw.handlers.marker = Object.assign({}, handldef.marker, rhand.marker);\r\n L.drawLocal.draw.handlers.polygon = Object.assign({}, handldef.polygon, rhand.polygon);\r\n L.drawLocal.draw.handlers.polyline = Object.assign({}, handldef.polyline, rhand.polyline);\r\n L.drawLocal.draw.handlers.rectangle = Object.assign({}, handldef.rectangle, rhand.rectangle);\r\n }\r\n\r\n // Create new Drawing Control\r\n map.drawToolbar = new L.Control.Draw(options);\r\n map.drawToolbar.addTo(map);\r\n\r\n // Event Listeners\r\n map.on(L.Draw.Event.DRAWSTART, function(e) {\r\n if (!HTMLWidgets.shinyMode) return;\r\n Shiny.onInputChange(map.id+'_draw_start', {'feature_type': e.layerType, 'nonce': Math.random()});\r\n });\r\n\r\n map.on(L.Draw.Event.DRAWSTOP, function(e) {\r\n if (!HTMLWidgets.shinyMode) return;\r\n Shiny.onInputChange(map.id+'_draw_stop', {'feature_type': e.layerType,'nonce': Math.random()});\r\n });\r\n\r\n map.on(L.Draw.Event.CREATED, function (e) {\r\n if (options.draw.singleFeature){\r\n if (editableFeatureGroup.getLayers().length > 0) {\r\n editableFeatureGroup.clearLayers();\r\n }\r\n }\r\n\r\n var layer = e.layer;\r\n editableFeatureGroup.addLayer(layer);\r\n\r\n // assign a unique key to the newly created feature\r\n var featureId = L.stamp(layer);\r\n layer.feature = {\r\n 'type' : 'Feature',\r\n 'properties' : {\r\n '_leaflet_id' : featureId,\r\n 'feature_type' : e.layerType\r\n }\r\n };\r\n\r\n // circles are just Points and toGeoJSON won't store radius by default\r\n // so we store it inside the properties.\r\n if(typeof layer.getRadius === 'function') {\r\n layer.feature.properties.radius = layer.getRadius();\r\n }\r\n\r\n if (!HTMLWidgets.shinyMode) return;\r\n\r\n Shiny.onInputChange(map.id+'_draw_new_feature',\r\n layer.toGeoJSON());\r\n Shiny.onInputChange(map.id+'_draw_all_features',\r\n editableFeatureGroup.toGeoJSON());\r\n });\r\n\r\n map.on(L.Draw.Event.EDITSTART, function () {\r\n if (!HTMLWidgets.shinyMode) return;\r\n Shiny.onInputChange(map.id+'_draw_editstart', true);\r\n });\r\n map.on(L.Draw.Event.EDITSTOP, function () {\r\n if (!HTMLWidgets.shinyMode) return;\r\n Shiny.onInputChange(map.id+'_draw_editstop', true);\r\n });\r\n\r\n map.on(L.Draw.Event.EDITED, function (e) {\r\n var layers = e.layers;\r\n layers.eachLayer(function(layer){\r\n var featureId = L.stamp(layer);\r\n if(!layer.feature) {\r\n layer.feature = {'type' : 'Feature'};\r\n }\r\n if(!layer.feature.properties) {\r\n layer.feature.properties = {};\r\n }\r\n layer.feature.properties._leaflet_id = featureId;\r\n layer.feature.properties.layerId = layer.options.layerId;\r\n if(typeof layer.getRadius === 'function') {\r\n layer.feature.properties.radius = layer.getRadius();\r\n }\r\n });\r\n\r\n if (!HTMLWidgets.shinyMode) return;\r\n\r\n Shiny.onInputChange(map.id+'_draw_edited_features',\r\n layers.toGeoJSON());\r\n Shiny.onInputChange(map.id+'_draw_all_features',\r\n editableFeatureGroup.toGeoJSON());\r\n });\r\n\r\n map.on(L.Draw.Event.DELETESTART, function () {\r\n if (!HTMLWidgets.shinyMode) return;\r\n Shiny.onInputChange(map.id+'_draw_deletestart', true);\r\n });\r\n\r\n map.on(L.Draw.Event.DELETESTOP, function () {\r\n if (!HTMLWidgets.shinyMode) return;\r\n Shiny.onInputChange(map.id+'_draw_deletestop', true);\r\n });\r\n\r\n map.on(L.Draw.Event.DELETED, function (e) {\r\n var layers = e.layers;\r\n layers.eachLayer(function(layer){\r\n var featureId = L.stamp(layer);\r\n if(!layer.feature) {\r\n layer.feature = {'type' : 'Feature'};\r\n }\r\n if(!layer.feature.properties) {\r\n layer.feature.properties = {};\r\n }\r\n layer.feature.properties._leaflet_id = featureId;\r\n layer.feature.properties.layerId = layer.options.layerId;\r\n if(typeof layer.getRadius === 'function') {\r\n layer.feature.properties.radius = layer.getRadius();\r\n }\r\n });\r\n\r\n if (!HTMLWidgets.shinyMode) return;\r\n Shiny.onInputChange(map.id+'_draw_deleted_features',\r\n layers.toGeoJSON());\r\n Shiny.onInputChange(map.id+'_draw_all_features',\r\n editableFeatureGroup.toGeoJSON());\r\n });\r\n\r\n }).call(this);\r\n\r\n};\r\n\r\nLeafletWidget.methods.removeDrawToolbar = function(clearFeatures) {\r\n (function(){\r\n\r\n var map = this;\r\n\r\n if(map.drawToolbar) {\r\n map.drawToolbar.remove(map);\r\n delete map.drawToolbar;\r\n }\r\n if(map._editableFeatureGroupName && clearFeatures) {\r\n var featureGroup = map.layerManager.getLayerGroup(map._editableFeatureGroupName, false);\r\n featureGroup.clearLayers();\r\n }\r\n map._editableFeatureGroupName = null;\r\n if(map._editableGeoJSONLayerId && clearFeatures) {\r\n map.layerManager.removeLayer('geojson', map._editableGeoJSONLayerId);\r\n }\r\n map._editableGeoJSONLayerId = null;\r\n }).call(this);\r\n\r\n};\r\n\r\n\r\n// TODO - not used for now. Missing R-function..Is it working?\r\nLeafletWidget.methods.getDrawnItems = function() {\r\n var map = this;\r\n\r\n var featureGroup;\r\n if(map._editableGeoJSONLayerId) {\r\n featureGroup = map.layerManager.getLayer('geojson', map._editableGeoJSONLayerId);\r\n } else if(map._editableFeatureGroupName) {\r\n featureGroup = map.layerManager.getLayerGroup(map._editableFeatureGroupName, false);\r\n }\r\n if(featureGroup) {\r\n return featureGroup.toGeoJSON();\r\n } else {\r\n return null;\r\n }\r\n\r\n};\r\n"],"names":["LeafletWidget","methods","addDrawToolbar","targetLayerId","targetGroup","options","editableFeatureGroup","map","this","drawToolbar","remove","layerManager","getLayer","_editableGeoJSONLayerId","getLayerGroup","_editableFeatureGroupName","draw","marker","markerIcon","markerIconFunction","icon","$","isEmptyObject","edit","editOptions","selectedPathOptions","poly","featureGroup","toolbar","rtool","tooldef","L","drawLocal","buttons","Object","assign","actions","finish","undo","handlers","rhand","handldef","circle","circlemarker","polygon","polyline","rectangle","Control","Draw","addTo","on","Event","DRAWSTART","e","HTMLWidgets","shinyMode","Shiny","onInputChange","id","layerType","Math","random","DRAWSTOP","CREATED","singleFeature","getLayers","length","clearLayers","layer","addLayer","featureId","stamp","feature","getRadius","properties","radius","toGeoJSON","EDITSTART","EDITSTOP","EDITED","layers","eachLayer","_leaflet_id","layerId","DELETESTART","DELETESTOP","DELETED","call","removeDrawToolbar","clearFeatures","removeLayer","getDrawnItems"],"sourceRoot":""} \ No newline at end of file diff --git a/inst/htmlwidgets/build/lfx-gps/lfx-gps-bindings.js b/inst/htmlwidgets/build/lfx-gps/lfx-gps-bindings.js index 556187b1..797e2666 100644 --- a/inst/htmlwidgets/build/lfx-gps/lfx-gps-bindings.js +++ b/inst/htmlwidgets/build/lfx-gps/lfx-gps-bindings.js @@ -1,2 +1,2 @@ -LeafletWidget.methods.addControlGPS=function(t){(function(){var o=this;o.gpscontrol&&(o.gpscontrol.remove(o),delete o.gpscontrol),o.gpscontrol=new L.Control.Gps(t),o.gpscontrol.on("gps:located",(function(t){HTMLWidgets.shinyMode&&Shiny.onInputChange(o.id+"_gps_located",{coordinates:t.latlng,radius:t.marker._radius})})),o.gpscontrol.on("gps:disabled",(function(t){HTMLWidgets.shinyMode&&Shiny.onInputChange(o.id+"_gps_disabled",{})})),o.gpscontrol.addTo(o)}).call(this)},LeafletWidget.methods.removeControlGPS=function(){(function(){var t=this;t.gpscontrol&&(t.gpscontrol.remove(t),delete t.gpscontrol)}).call(this)},LeafletWidget.methods.activateGPS=function(){(function(){this.gpscontrol&&this.gpscontrol.activate()}).call(this)},LeafletWidget.methods.deactivateGPS=function(){(function(){this.gpscontrol&&this.gpscontrol.deactivate()}).call(this)},LeafletWidget.methods.getLocation=function(){return function(){if(this.gpscontrol)return this.gpscontrol.getLocation();throw"GPS Control not added to the map"}.call(this)}; +LeafletWidget.methods.addControlGPS=function(t){(function(){var o=this;o.gpscontrol&&(o.gpscontrol.remove(o),delete o.gpscontrol),o.gpscontrol=new L.Control.Gps(t),o.gpscontrol.on("gps:located",(function(t){HTMLWidgets.shinyMode&&Shiny.onInputChange(o.id+"_gps_located",{coordinates:t.latlng,radius:t.marker._radius})})),o.gpscontrol.on("gps:disabled",(function(){HTMLWidgets.shinyMode&&Shiny.onInputChange(o.id+"_gps_disabled",{})})),o.gpscontrol.addTo(o)}).call(this)},LeafletWidget.methods.removeControlGPS=function(){(function(){var t=this;t.gpscontrol&&(t.gpscontrol.remove(t),delete t.gpscontrol)}).call(this)},LeafletWidget.methods.activateGPS=function(){(function(){this.gpscontrol&&this.gpscontrol.activate()}).call(this)},LeafletWidget.methods.deactivateGPS=function(){(function(){this.gpscontrol&&this.gpscontrol.deactivate()}).call(this)},LeafletWidget.methods.getLocation=function(){return function(){if(this.gpscontrol)return this.gpscontrol.getLocation();throw"GPS Control not added to the map"}.call(this)}; //# sourceMappingURL=lfx-gps-bindings.js.map \ No newline at end of file diff --git a/inst/htmlwidgets/build/lfx-gps/lfx-gps-bindings.js.map b/inst/htmlwidgets/build/lfx-gps/lfx-gps-bindings.js.map index 68e82f23..521003e6 100644 --- a/inst/htmlwidgets/build/lfx-gps/lfx-gps-bindings.js.map +++ b/inst/htmlwidgets/build/lfx-gps/lfx-gps-bindings.js.map @@ -1 +1 @@ -{"version":3,"file":"lfx-gps-bindings.js","mappings":"AAEAA,cAAcC,QAAQC,cAAgB,SAASC,IAC7C,WACE,IAAIC,EAAMC,KACPD,EAAIE,aACLF,EAAIE,WAAWC,OAAOH,UACfA,EAAIE,YAEbF,EAAIE,WAAa,IAAIE,EAAEC,QAAQC,IAAIP,GAEnCC,EAAIE,WAAWK,GAAG,eAAe,SAASC,GAEnCC,YAAYC,WACjBC,MAAMC,cAAcZ,EAAIa,GAAG,eAAe,CACxC,YAAgBL,EAAEM,OAClB,OAAUN,EAAEO,OAAOC,SAEvB,IACAhB,EAAIE,WAAWK,GAAG,gBAAgB,SAASC,GAEpCC,YAAYC,WACjBC,MAAMC,cAAcZ,EAAIa,GAAG,gBAAgB,CAAC,EAC9C,IACAb,EAAIE,WAAWe,MAAMjB,EACtB,GAAEkB,KAAKjB,KACV,EAEAL,cAAcC,QAAQsB,iBAAmB,YACvC,WACE,IAAInB,EAAMC,KACPD,EAAIE,aACLF,EAAIE,WAAWC,OAAOH,UACfA,EAAIE,WAEd,GAAEgB,KAAKjB,KACV,EAEAL,cAAcC,QAAQuB,YAAc,YAClC,WACYnB,KACHC,YADGD,KAEJC,WAAWmB,UAElB,GAAEH,KAAKjB,KACV,EAEAL,cAAcC,QAAQyB,cAAgB,YACpC,WACYrB,KACHC,YADGD,KAEJC,WAAWqB,YAElB,GAAEL,KAAKjB,KACV,EAEAL,cAAcC,QAAQ2B,YAAc,WAClC,OAAO,WAEL,GADUvB,KACHC,WACL,OAFQD,KAEGC,WAAWsB,cAEtB,KAAM,kCAET,EAAEN,KAAKjB,KACV","sources":["webpack://leaflet.extras/./inst/htmlwidgets/bindings/lfx-gps-bindings.js"],"sourcesContent":["/* global LeafletWidget, L, HTMLWidgets, Shiny */\r\n\r\nLeafletWidget.methods.addControlGPS = function(options) {\r\n (function() {\r\n var map = this;\r\n if(map.gpscontrol) {\r\n map.gpscontrol.remove(map);\r\n delete map.gpscontrol;\r\n }\r\n map.gpscontrol = new L.Control.Gps(options);\r\n\r\n map.gpscontrol.on('gps:located', function(e){\r\n // Shiny stuff\r\n if (!HTMLWidgets.shinyMode) return;\r\n Shiny.onInputChange(map.id+'_gps_located',{\r\n 'coordinates' : e.latlng,\r\n 'radius': e.marker._radius\r\n });\r\n });\r\n map.gpscontrol.on('gps:disabled', function(e){\r\n // Shiny stuff\r\n if (!HTMLWidgets.shinyMode) return;\r\n Shiny.onInputChange(map.id+'_gps_disabled',{});\r\n });\r\n map.gpscontrol.addTo(map);\r\n }).call(this);\r\n};\r\n\r\nLeafletWidget.methods.removeControlGPS = function() {\r\n (function() {\r\n var map = this;\r\n if(map.gpscontrol) {\r\n map.gpscontrol.remove(map);\r\n delete map.gpscontrol;\r\n }\r\n }).call(this);\r\n};\r\n\r\nLeafletWidget.methods.activateGPS = function() {\r\n (function() {\r\n var map = this;\r\n if(map.gpscontrol) {\r\n map.gpscontrol.activate();\r\n }\r\n }).call(this);\r\n};\r\n\r\nLeafletWidget.methods.deactivateGPS = function() {\r\n (function() {\r\n var map = this;\r\n if(map.gpscontrol) {\r\n map.gpscontrol.deactivate();\r\n }\r\n }).call(this);\r\n};\r\n\r\nLeafletWidget.methods.getLocation = function() {\r\n return (function() {\r\n var map = this;\r\n if(map.gpscontrol) {\r\n return map.gpscontrol.getLocation();\r\n } else {\r\n throw 'GPS Control not added to the map';\r\n }\r\n }).call(this);\r\n};\r\n"],"names":["LeafletWidget","methods","addControlGPS","options","map","this","gpscontrol","remove","L","Control","Gps","on","e","HTMLWidgets","shinyMode","Shiny","onInputChange","id","latlng","marker","_radius","addTo","call","removeControlGPS","activateGPS","activate","deactivateGPS","deactivate","getLocation"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"lfx-gps-bindings.js","mappings":"AAEAA,cAAcC,QAAQC,cAAgB,SAASC,IAC7C,WACE,IAAIC,EAAMC,KACPD,EAAIE,aACLF,EAAIE,WAAWC,OAAOH,UACfA,EAAIE,YAEbF,EAAIE,WAAa,IAAIE,EAAEC,QAAQC,IAAIP,GAEnCC,EAAIE,WAAWK,GAAG,eAAe,SAASC,GAEnCC,YAAYC,WACjBC,MAAMC,cAAcZ,EAAIa,GAAG,eAAe,CACxC,YAAgBL,EAAEM,OAClB,OAAUN,EAAEO,OAAOC,SAEvB,IACAhB,EAAIE,WAAWK,GAAG,gBAAgB,WAE3BE,YAAYC,WACjBC,MAAMC,cAAcZ,EAAIa,GAAG,gBAAgB,CAAC,EAC9C,IACAb,EAAIE,WAAWe,MAAMjB,EACtB,GAAEkB,KAAKjB,KACV,EAEAL,cAAcC,QAAQsB,iBAAmB,YACvC,WACE,IAAInB,EAAMC,KACPD,EAAIE,aACLF,EAAIE,WAAWC,OAAOH,UACfA,EAAIE,WAEd,GAAEgB,KAAKjB,KACV,EAEAL,cAAcC,QAAQuB,YAAc,YAClC,WACYnB,KACHC,YADGD,KAEJC,WAAWmB,UAElB,GAAEH,KAAKjB,KACV,EAEAL,cAAcC,QAAQyB,cAAgB,YACpC,WACYrB,KACHC,YADGD,KAEJC,WAAWqB,YAElB,GAAEL,KAAKjB,KACV,EAEAL,cAAcC,QAAQ2B,YAAc,WAClC,OAAO,WAEL,GADUvB,KACHC,WACL,OAFQD,KAEGC,WAAWsB,cAEtB,KAAM,kCAET,EAAEN,KAAKjB,KACV","sources":["webpack://leaflet.extras/./inst/htmlwidgets/bindings/lfx-gps-bindings.js"],"sourcesContent":["/* global LeafletWidget, L, HTMLWidgets, Shiny */\r\n\r\nLeafletWidget.methods.addControlGPS = function(options) {\r\n (function() {\r\n var map = this;\r\n if(map.gpscontrol) {\r\n map.gpscontrol.remove(map);\r\n delete map.gpscontrol;\r\n }\r\n map.gpscontrol = new L.Control.Gps(options);\r\n\r\n map.gpscontrol.on('gps:located', function(e){\r\n // Shiny stuff\r\n if (!HTMLWidgets.shinyMode) return;\r\n Shiny.onInputChange(map.id+'_gps_located',{\r\n 'coordinates' : e.latlng,\r\n 'radius': e.marker._radius\r\n });\r\n });\r\n map.gpscontrol.on('gps:disabled', function(){\r\n // Shiny stuff\r\n if (!HTMLWidgets.shinyMode) return;\r\n Shiny.onInputChange(map.id+'_gps_disabled',{});\r\n });\r\n map.gpscontrol.addTo(map);\r\n }).call(this);\r\n};\r\n\r\nLeafletWidget.methods.removeControlGPS = function() {\r\n (function() {\r\n var map = this;\r\n if(map.gpscontrol) {\r\n map.gpscontrol.remove(map);\r\n delete map.gpscontrol;\r\n }\r\n }).call(this);\r\n};\r\n\r\nLeafletWidget.methods.activateGPS = function() {\r\n (function() {\r\n var map = this;\r\n if(map.gpscontrol) {\r\n map.gpscontrol.activate();\r\n }\r\n }).call(this);\r\n};\r\n\r\nLeafletWidget.methods.deactivateGPS = function() {\r\n (function() {\r\n var map = this;\r\n if(map.gpscontrol) {\r\n map.gpscontrol.deactivate();\r\n }\r\n }).call(this);\r\n};\r\n\r\nLeafletWidget.methods.getLocation = function() {\r\n return (function() {\r\n var map = this;\r\n if(map.gpscontrol) {\r\n return map.gpscontrol.getLocation();\r\n } else {\r\n throw 'GPS Control not added to the map';\r\n }\r\n }).call(this);\r\n};\r\n"],"names":["LeafletWidget","methods","addControlGPS","options","map","this","gpscontrol","remove","L","Control","Gps","on","e","HTMLWidgets","shinyMode","Shiny","onInputChange","id","latlng","marker","_radius","addTo","call","removeControlGPS","activateGPS","activate","deactivateGPS","deactivate","getLocation"],"sourceRoot":""} \ No newline at end of file diff --git a/inst/htmlwidgets/build/lfx-search/lfx-search-bindings.js b/inst/htmlwidgets/build/lfx-search/lfx-search-bindings.js index f6e3b7ce..5b57554b 100644 --- a/inst/htmlwidgets/build/lfx-search/lfx-search-bindings.js +++ b/inst/htmlwidgets/build/lfx-search/lfx-search-bindings.js @@ -1,2 +1,2 @@ -(()=>{function e(e){var o={latlng:{}};return o.latlng.lat=e.latlng.lat,o.latlng.lng=e.latlng.lng,$.isEmptyObject(e.title)||(o.title=e.title),$.isEmptyObject(e.layer)||(o.layer=e.layer.toGeoJSON()),o}var o,t;LeafletWidget.methods.addSearchOSM=function(o){(function(){var t=this;t.searchControlOSM&&(t.searchControlOSM.remove(t),delete t.searchControlOSM),(o=o||{}).textPlaceholder=o.textPlaceholder?o.textPlaceholder:"Search using OSM Geocoder",o.url=o.url?o.url:"https://nominatim.openstreetmap.org/search?format=json&q={s}",o.jsonpParam=o.jsonpParam?o.jsonpParam:"json_callback",o.propertyName=o.propertyName?o.propertyName:"display_name",o.propertyLoc=o.propertyLoc?o.propertyLoc:["lat","lon"],o.marker=L.circleMarker([0,0],{radius:30}),o.moveToLocation&&(o.moveToLocation=function(e,t,r){var a=o.zoom||16,n=r.getMaxZoom();n&&a>n&&(a=n),r.setView(e,a)}),t.searchControlOSM=new L.Control.Search(o),t.searchControlOSM.addTo(t),t.searchControlOSM.on("search:locationfound",(function(o){HTMLWidgets.shinyMode&&Shiny.onInputChange(t.id+"_search_location_found",e(o))}))}).call(this)},LeafletWidget.methods.removeSearchOSM=function(){(function(){var e=this;e.searchControlOSM&&(e.searchControlOSM.remove(e),delete e.searchControlOSM);var t=document.getElementById("reverseSearchOSM");t&&(t.remove(),e.off("click",o))}).call(this)},LeafletWidget.methods.addReverseSearchOSM=function(e,t){(function(){var r=this;t=t||"reverse_search_osm",r.layerManager.clearGroup(t);var a=document.getElementById("reverseSearchOSM");o=function(o){var n=o.latlng,l=L.featureGroup(),s=L.stamp(l);if(e.showSearchLocation){var c=L.marker(o.latlng,{type:"query"}).bindTooltip("lat="+n.lat+" lng="+n.lng+"

");L.stamp(c),l.addLayer(c)}var i="https://nominatim.openstreetmap.org/reverse?format=json&polygon_geojson=1&lat="+n.lat+"&lon="+n.lng;$.ajax({url:i,dataType:"json"}).done((function(o){if(o.error&&"Unable to geocode"===o.error)a.innerHTML="Unable to geocode";else{if(!$.isEmptyObject(a)){var i="
";i=i+"Display Name: "+(o.display_name?o.display_name:"")+"
",i+="
",a.innerHTML=i}var d=L.latLngBounds(L.latLng(o.boundingbox[0],o.boundingbox[2]),L.latLng(o.boundingbox[1],o.boundingbox[3]));if(e.showBounds){var u=L.rectangle(d,{weight:2,color:"#444444",clickable:!1,dashArray:"5,10",type:"result_boundingbox"});L.stamp(u),l.addLayer(u)}if(e.showFeature){var h=L.geoJson(o.geojson,{weight:2,color:"red",dashArray:"5,10",clickable:!1,type:"result_feature",pointToLayer:function(e,o){return L.circleMarker(o,{weight:2,color:"red",dashArray:"5,10",clickable:!1})}});L.stamp(h),l.addLayer(h)}var g=l.getLayers();!$.isEmptyObject(g)&&g.length>=0&&($.isEmptyObject(c)||(c.on("mouseover",(function(e){$.isEmptyObject(u)||(u.setStyle({fillOpacity:.5,opacity:.8,weight:5}),u.bringToFront()),$.isEmptyObject(h)||(h.setStyle({fillOpacity:.5,opacity:.8,weight:5}),h.bringToFront())})),c.on("mouseout",(function(e){$.isEmptyObject(u)||(u.setStyle({fillOpacity:.2,opacity:.5,weight:2}),u.bringToBack()),$.isEmptyObject(h)||(h.setStyle({fillOpacity:.2,opacity:.5,weight:2}),h.bringToBack())}))),r.layerManager.addLayer(l,"search",s,t),e.fitBounds&&r.fitBounds(l.getBounds())),HTMLWidgets.shinyMode&&Shiny.onInputChange(r.id+"_reverse_search_feature_found",{query:{lat:n.lat,lng:n.lng},result:o})}}))},r.on("click",o)}).call(this)},LeafletWidget.methods.searchOSMText=function(e){(function(){this.searchControlOSM&&this.searchControlOSM.searchText(e)}).call(this)},LeafletWidget.methods.addSearchGoogle=function(o){(function(){var t=this;t.searchControlGoogle&&(t.searchControlGoogle.remove(t),delete t.searchControlGoogle);var r=new google.maps.Geocoder;(o=o||{}).markerLocation=!0,o.textPlaceholder=o.textPlaceholder?o.textPlaceholder:"Search using Google Geocoder",o.marker=L.circleMarker([0,0],{radius:30}),o.moveToLocation&&(o.moveToLocation=function(e,t,r){var a=o.zoom||16,n=r.getMaxZoom();n&&a>n&&(a=n),r.setView(e,a)}),o.sourceData=function(e,o){r.geocode({address:e},o)},o.formatData=function(e){var o,t,r={};for(var a in e)o=e[a].formatted_address,t=L.latLng(e[a].geometry.location.lat(),e[a].geometry.location.lng()),r[o]=t;return r},t.searchControlGoogle=new L.Control.Search(o),t.searchControlGoogle.addTo(t),t.searchControlGoogle.on("search:locationfound",(function(o){HTMLWidgets.shinyMode&&Shiny.onInputChange(t.id+"_search_location_found",e(o))}))}).call(this)},LeafletWidget.methods.removeSearchGoogle=function(){(function(){var e=this;e.searchControlGoogle&&(e.searchControlGoogle.remove(e),delete e.searchControlGoogle);var o=document.getElementById("reverseSearchGoogle");o&&(o.remove(),e.off("click",t))}).call(this)},LeafletWidget.methods.addReverseSearchGoogle=function(e,o){(function(){var r=this;o=o||"reverse_search_google",r.layerManager.clearGroup(o);var a=document.getElementById("reverseSearchGoogle"),n=new google.maps.Geocoder;t=function(t){var l=t.latlng,s=L.featureGroup(),c=L.stamp(s);if(e.showSearchLocation){var i=L.marker(t.latlng,{type:"query"}).bindTooltip("lat="+l.lat+" lng="+l.lng+"

");L.stamp(i),s.addLayer(i)}n.geocode({location:{lat:l.lat,lng:l.lng}},(function(t,n){if("OK"===n)if(t[0]){var d=t[0];if(!$.isEmptyObject(a)){var u="
";u=u+"Address: "+(d.formatted_address?d.formatted_address:"")+"
",u+="
",a.innerHTML=u}var h=L.latLngBounds(L.latLng(d.geometry.viewport.f.f,d.geometry.viewport.b.b),L.latLng(d.geometry.viewport.f.b,d.geometry.viewport.b.f));if(e.showBounds){var g=L.rectangle(h,{weight:2,color:"#444444",clickable:!1,dashArray:"5,10",type:"result_boundingbox"});L.stamp(g),s.addLayer(g)}if(e.showFeature){var m=L.circleMarker(L.latLng(d.geometry.location.lat(),d.geometry.location.lng()),{weight:2,color:"red",dashArray:"5,10",clickable:!1,type:"result_feature"});L.stamp(m),s.addLayer(m)}var y=s.getLayers();!$.isEmptyObject(y)&&y.length>=0&&($.isEmptyObject(i)||(i.on("mouseover",(function(e){$.isEmptyObject(g)||(g.setStyle({fillOpacity:.5,opacity:.8,weight:5}),g.bringToFront()),$.isEmptyObject(m)||(m.setStyle({fillOpacity:.5,opacity:.8,weight:5}),m.bringToFront())})),i.on("mouseout",(function(e){$.isEmptyObject(g)||(g.setStyle({fillOpacity:.2,opacity:.5,weight:2}),g.bringToBack()),$.isEmptyObject(m)||(m.setStyle({fillOpacity:.2,opacity:.5,weight:2}),m.bringToBack())}))),r.layerManager.addLayer(s,"search",c,o),e.fitBounds&&r.fitBounds(s.getBounds())),HTMLWidgets.shinyMode&&Shiny.onInputChange(r.id+"_reverse_search_feature_found",{query:{lat:l.lat,lng:l.lng},result:d})}else $.isEmptyObject(a)||(a.innerHTML="No Results Found"),console.error("No Results Found");else $.isEmptyObject(a)||(a.innerHTML="Reverse Geocoding failed due to: "+n),console.error("Reverse Geocoing failed due to: "+n)}))},r.on("click",t)}).call(this)},LeafletWidget.methods.addSearchUSCensusBureau=function(o){(function(){var t=this;t.searchControlUSCensusBureau&&(t.searchControlUSCensusBureau.remove(t),delete t.searchControlUSCensusBureau),(o=o||{}).url=o.url?o.url:"https://geocoding.geo.census.gov/geocoder/locations/onelineaddress?benchmark=Public_AR_Current&format=jsonp&address={s}",o.textPlaceholder=o.textPlaceholder?o.textPlaceholder:"Search using US Census Bureau TEST",o.jsonpParam=o.jsonpParam?o.jsonpParam:"callback",o.formatData=function(e){var o,t,r={};for(var a in e.result.addressMatches)o=e.result.addressMatches[a].matchedAddress,t=L.latLng(e.result.addressMatches[a].coordinates.y,e.result.addressMatches[a].coordinates.x),r[o]=t;return r},o.marker=L.circleMarker([0,0],{radius:30}),o.moveToLocation&&(o.moveToLocation=function(e,t,r){var a=o.zoom||16,n=r.getMaxZoom();n&&a>n&&(a=n),r.setView(e,a)}),t.searchControlUSCensusBureau=new L.Control.Search(o),t.searchControlUSCensusBureau.addTo(t),t.searchControlUSCensusBureau.on("search:locationfound",(function(o){HTMLWidgets.shinyMode&&Shiny.onInputChange(t.id+"_search_location_found",e(o))}))}).call(this)},LeafletWidget.methods.removeSearchUSCensusBureau=function(){(function(){var e=this;e.searchControlUSCensusBureau&&(e.searchControlUSCensusBureau.remove(e),delete e.searchControlUSCensusBureau)}).call(this)},LeafletWidget.methods.addSearchFeatures=function(o,t){(function(){var r,a=this;if(a.searchControl&&(a.searchControl.remove(a),delete a.searchControl),(t=t||{}).moveToLocation&&(t.moveToLocation=function(e,o,r){var a=t.zoom||16,n=r.getMaxZoom();n&&a>n&&(a=n),r.setView(e,a)}),L.Util.isArray(o))r=a.layerManager.getLayerGroup("search",!0),a._searchFeatureGroupName="search",$.each(o,(function(e,o){var t=a.layerManager.getLayerGroup(o,!1);t?r.addLayer(t):console.warn('Group with ID "'+o+'" not Found, skipping')}));else{var n=a.layerManager.getLayerGroup(o,!1);if(!n)throw'Group with ID "'+o+'" not found';r=n,a._searchFeatureGroupName=o}L.stamp(r),t.layer=r,a.searchControl=new L.Control.Search(t),a.searchControl.addTo(a),a.searchControl.on("search:locationfound",(function(o){t.openPopup&&o.layer._popup&&o.layer.openPopup(),HTMLWidgets.shinyMode&&Shiny.onInputChange(a.id+"_search_location_found",e(o))}))}).call(this)},LeafletWidget.methods.removeSearchFeatures=function(e){(function(){var o=this;o.searchControl&&(o.searchControl.remove(o),delete o.searchControl),e&&o._searchFeatureGroupName&&(o.layerManager.clearGroup(o._searchFeatureGroupName),delete o._searchFeatureGroupName)}).call(this)}})(); +(()=>{function e(e){var o={latlng:{}};return o.latlng.lat=e.latlng.lat,o.latlng.lng=e.latlng.lng,$.isEmptyObject(e.title)||(o.title=e.title),$.isEmptyObject(e.layer)||(o.layer=e.layer.toGeoJSON()),o}var o,t;LeafletWidget.methods.addSearchOSM=function(o){(function(){var t=this;t.searchControlOSM&&(t.searchControlOSM.remove(t),delete t.searchControlOSM),(o=o||{}).textPlaceholder=o.textPlaceholder?o.textPlaceholder:"Search using OSM Geocoder",o.url=o.url?o.url:"https://nominatim.openstreetmap.org/search?format=json&q={s}",o.jsonpParam=o.jsonpParam?o.jsonpParam:"json_callback",o.propertyName=o.propertyName?o.propertyName:"display_name",o.propertyLoc=o.propertyLoc?o.propertyLoc:["lat","lon"],o.marker=L.circleMarker([0,0],{radius:30}),o.moveToLocation&&(o.moveToLocation=function(e,t,r){var a=o.zoom||16,n=r.getMaxZoom();n&&a>n&&(a=n),r.setView(e,a)}),t.searchControlOSM=new L.Control.Search(o),t.searchControlOSM.addTo(t),t.searchControlOSM.on("search:locationfound",(function(o){HTMLWidgets.shinyMode&&Shiny.onInputChange(t.id+"_search_location_found",e(o))}))}).call(this)},LeafletWidget.methods.removeSearchOSM=function(){(function(){var e=this;e.searchControlOSM&&(e.searchControlOSM.remove(e),delete e.searchControlOSM);var t=document.getElementById("reverseSearchOSM");t&&(t.remove(),e.off("click",o))}).call(this)},LeafletWidget.methods.addReverseSearchOSM=function(e,t){(function(){var r=this;t=t||"reverse_search_osm",r.layerManager.clearGroup(t);var a=document.getElementById("reverseSearchOSM");o=function(o){var n=o.latlng,l=L.featureGroup(),s=L.stamp(l);if(e.showSearchLocation){var c=L.marker(o.latlng,{type:"query"}).bindTooltip("lat="+n.lat+" lng="+n.lng+"

");L.stamp(c),l.addLayer(c)}var i="https://nominatim.openstreetmap.org/reverse?format=json&polygon_geojson=1&lat="+n.lat+"&lon="+n.lng;$.ajax({url:i,dataType:"json"}).done((function(o){if(o.error&&"Unable to geocode"===o.error)a.innerHTML="Unable to geocode";else{if(!$.isEmptyObject(a)){var i="
";i=i+"Display Name: "+(o.display_name?o.display_name:"")+"
",i+="
",a.innerHTML=i}var d=L.latLngBounds(L.latLng(o.boundingbox[0],o.boundingbox[2]),L.latLng(o.boundingbox[1],o.boundingbox[3]));if(e.showBounds){var u=L.rectangle(d,{weight:2,color:"#444444",clickable:!1,dashArray:"5,10",type:"result_boundingbox"});L.stamp(u),l.addLayer(u)}if(e.showFeature){var h=L.geoJson(o.geojson,{weight:2,color:"red",dashArray:"5,10",clickable:!1,type:"result_feature",pointToLayer:function(e,o){return L.circleMarker(o,{weight:2,color:"red",dashArray:"5,10",clickable:!1})}});L.stamp(h),l.addLayer(h)}var g=l.getLayers();!$.isEmptyObject(g)&&g.length>=0&&($.isEmptyObject(c)||(c.on("mouseover",(function(){$.isEmptyObject(u)||(u.setStyle({fillOpacity:.5,opacity:.8,weight:5}),u.bringToFront()),$.isEmptyObject(h)||(h.setStyle({fillOpacity:.5,opacity:.8,weight:5}),h.bringToFront())})),c.on("mouseout",(function(){$.isEmptyObject(u)||(u.setStyle({fillOpacity:.2,opacity:.5,weight:2}),u.bringToBack()),$.isEmptyObject(h)||(h.setStyle({fillOpacity:.2,opacity:.5,weight:2}),h.bringToBack())}))),r.layerManager.addLayer(l,"search",s,t),e.fitBounds&&r.fitBounds(l.getBounds())),HTMLWidgets.shinyMode&&Shiny.onInputChange(r.id+"_reverse_search_feature_found",{query:{lat:n.lat,lng:n.lng},result:o})}}))},r.on("click",o)}).call(this)},LeafletWidget.methods.searchOSMText=function(e){(function(){this.searchControlOSM&&this.searchControlOSM.searchText(e)}).call(this)},LeafletWidget.methods.addSearchGoogle=function(o){(function(){var t=this;t.searchControlGoogle&&(t.searchControlGoogle.remove(t),delete t.searchControlGoogle);var r=new google.maps.Geocoder;(o=o||{}).markerLocation=!0,o.textPlaceholder=o.textPlaceholder?o.textPlaceholder:"Search using Google Geocoder",o.marker=L.circleMarker([0,0],{radius:30}),o.moveToLocation&&(o.moveToLocation=function(e,t,r){var a=o.zoom||16,n=r.getMaxZoom();n&&a>n&&(a=n),r.setView(e,a)}),o.sourceData=function(e,o){r.geocode({address:e},o)},o.formatData=function(e){var o,t,r={};for(var a in e)o=e[a].formatted_address,t=L.latLng(e[a].geometry.location.lat(),e[a].geometry.location.lng()),r[o]=t;return r},t.searchControlGoogle=new L.Control.Search(o),t.searchControlGoogle.addTo(t),t.searchControlGoogle.on("search:locationfound",(function(o){HTMLWidgets.shinyMode&&Shiny.onInputChange(t.id+"_search_location_found",e(o))}))}).call(this)},LeafletWidget.methods.removeSearchGoogle=function(){(function(){var e=this;e.searchControlGoogle&&(e.searchControlGoogle.remove(e),delete e.searchControlGoogle);var o=document.getElementById("reverseSearchGoogle");o&&(o.remove(),e.off("click",t))}).call(this)},LeafletWidget.methods.addReverseSearchGoogle=function(e,o){(function(){var r=this;o=o||"reverse_search_google",r.layerManager.clearGroup(o);var a=document.getElementById("reverseSearchGoogle"),n=new google.maps.Geocoder;t=function(t){var l=t.latlng,s=L.featureGroup(),c=L.stamp(s);if(e.showSearchLocation){var i=L.marker(t.latlng,{type:"query"}).bindTooltip("lat="+l.lat+" lng="+l.lng+"

");L.stamp(i),s.addLayer(i)}n.geocode({location:{lat:l.lat,lng:l.lng}},(function(t,n){if("OK"===n)if(t[0]){var d=t[0];if(!$.isEmptyObject(a)){var u="
";u=u+"Address: "+(d.formatted_address?d.formatted_address:"")+"
",u+="
",a.innerHTML=u}var h=L.latLngBounds(L.latLng(d.geometry.viewport.f.f,d.geometry.viewport.b.b),L.latLng(d.geometry.viewport.f.b,d.geometry.viewport.b.f));if(e.showBounds){var g=L.rectangle(h,{weight:2,color:"#444444",clickable:!1,dashArray:"5,10",type:"result_boundingbox"});L.stamp(g),s.addLayer(g)}if(e.showFeature){var m=L.circleMarker(L.latLng(d.geometry.location.lat(),d.geometry.location.lng()),{weight:2,color:"red",dashArray:"5,10",clickable:!1,type:"result_feature"});L.stamp(m),s.addLayer(m)}var y=s.getLayers();!$.isEmptyObject(y)&&y.length>=0&&($.isEmptyObject(i)||(i.on("mouseover",(function(e){$.isEmptyObject(g)||(g.setStyle({fillOpacity:.5,opacity:.8,weight:5}),g.bringToFront()),$.isEmptyObject(m)||(m.setStyle({fillOpacity:.5,opacity:.8,weight:5}),m.bringToFront())})),i.on("mouseout",(function(e){$.isEmptyObject(g)||(g.setStyle({fillOpacity:.2,opacity:.5,weight:2}),g.bringToBack()),$.isEmptyObject(m)||(m.setStyle({fillOpacity:.2,opacity:.5,weight:2}),m.bringToBack())}))),r.layerManager.addLayer(s,"search",c,o),e.fitBounds&&r.fitBounds(s.getBounds())),HTMLWidgets.shinyMode&&Shiny.onInputChange(r.id+"_reverse_search_feature_found",{query:{lat:l.lat,lng:l.lng},result:d})}else $.isEmptyObject(a)||(a.innerHTML="No Results Found"),console.error("No Results Found");else $.isEmptyObject(a)||(a.innerHTML="Reverse Geocoding failed due to: "+n),console.error("Reverse Geocoing failed due to: "+n)}))},r.on("click",t)}).call(this)},LeafletWidget.methods.addSearchUSCensusBureau=function(o){(function(){var t=this;t.searchControlUSCensusBureau&&(t.searchControlUSCensusBureau.remove(t),delete t.searchControlUSCensusBureau),(o=o||{}).url=o.url?o.url:"https://geocoding.geo.census.gov/geocoder/locations/onelineaddress?benchmark=Public_AR_Current&format=jsonp&address={s}",o.textPlaceholder=o.textPlaceholder?o.textPlaceholder:"Search using US Census Bureau TEST",o.jsonpParam=o.jsonpParam?o.jsonpParam:"callback",o.formatData=function(e){var o,t,r={};for(var a in e.result.addressMatches)o=e.result.addressMatches[a].matchedAddress,t=L.latLng(e.result.addressMatches[a].coordinates.y,e.result.addressMatches[a].coordinates.x),r[o]=t;return r},o.marker=L.circleMarker([0,0],{radius:30}),o.moveToLocation&&(o.moveToLocation=function(e,t,r){var a=o.zoom||16,n=r.getMaxZoom();n&&a>n&&(a=n),r.setView(e,a)}),t.searchControlUSCensusBureau=new L.Control.Search(o),t.searchControlUSCensusBureau.addTo(t),t.searchControlUSCensusBureau.on("search:locationfound",(function(o){HTMLWidgets.shinyMode&&Shiny.onInputChange(t.id+"_search_location_found",e(o))}))}).call(this)},LeafletWidget.methods.removeSearchUSCensusBureau=function(){(function(){var e=this;e.searchControlUSCensusBureau&&(e.searchControlUSCensusBureau.remove(e),delete e.searchControlUSCensusBureau)}).call(this)},LeafletWidget.methods.addSearchFeatures=function(o,t){(function(){var r,a=this;if(a.searchControl&&(a.searchControl.remove(a),delete a.searchControl),(t=t||{}).moveToLocation&&(t.moveToLocation=function(e,o,r){var a=t.zoom||16,n=r.getMaxZoom();n&&a>n&&(a=n),r.setView(e,a)}),L.Util.isArray(o))r=a.layerManager.getLayerGroup("search",!0),a._searchFeatureGroupName="search",$.each(o,(function(e,o){var t=a.layerManager.getLayerGroup(o,!1);t?r.addLayer(t):console.warn('Group with ID "'+o+'" not Found, skipping')}));else{var n=a.layerManager.getLayerGroup(o,!1);if(!n)throw'Group with ID "'+o+'" not found';r=n,a._searchFeatureGroupName=o}L.stamp(r),t.layer=r,a.searchControl=new L.Control.Search(t),a.searchControl.addTo(a),a.searchControl.on("search:locationfound",(function(o){t.openPopup&&o.layer._popup&&o.layer.openPopup(),HTMLWidgets.shinyMode&&Shiny.onInputChange(a.id+"_search_location_found",e(o))}))}).call(this)},LeafletWidget.methods.removeSearchFeatures=function(e){(function(){var o=this;o.searchControl&&(o.searchControl.remove(o),delete o.searchControl),e&&o._searchFeatureGroupName&&(o.layerManager.clearGroup(o._searchFeatureGroupName),delete o._searchFeatureGroupName)}).call(this)}})(); //# sourceMappingURL=lfx-search-bindings.js.map \ No newline at end of file diff --git a/inst/htmlwidgets/build/lfx-search/lfx-search-bindings.js.map b/inst/htmlwidgets/build/lfx-search/lfx-search-bindings.js.map index 45b90fde..d8ee5ead 100644 --- a/inst/htmlwidgets/build/lfx-search/lfx-search-bindings.js.map +++ b/inst/htmlwidgets/build/lfx-search/lfx-search-bindings.js.map @@ -1 +1 @@ -{"version":3,"file":"lfx-search-bindings.js","mappings":"MAGA,SAASA,EAAaC,GACpB,IAAIC,EAAa,CACjBA,OAAoB,CAAC,GASrB,OARAA,EAAWC,OAAOC,IAAMH,EAAEE,OAAOC,IACjCF,EAAWC,OAAOE,IAAMJ,EAAEE,OAAOE,IAC7BC,EAAEC,cAAcN,EAAEO,SACpBN,EAAWM,MAAQP,EAAEO,OAEnBF,EAAEC,cAAcN,EAAEQ,SACpBP,EAAWO,MAAQR,EAAEQ,MAAMC,aAEtBR,CACT,CA6CA,IAAIS,EAoNAC,EA/PJC,cAAcC,QAAQC,aAAe,SAASC,IAE5C,WACE,IAAIC,EAAMC,KAEPD,EAAIE,mBACLF,EAAIE,iBAAiBC,OAAOH,UACrBA,EA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YC,WACjBC,MAAMC,cAAczB,EAAI0B,GAAG,yBAA0B3C,EAAaC,GACpE,GAED,GAAE2C,KAAK1B,KACV,EAEAL,cAAcC,QAAQ0I,qBAAuB,SAASC,IACpD,WACE,IAAIxI,EAAMC,KACND,EAAI2H,gBACN3H,EAAI2H,cAAcxH,OAAOH,UAClBA,EAAI2H,eAETa,GAAiBxI,EAAI+H,0BACvB/H,EAAImC,aAAaC,WAAWpC,EAAI+H,gCACzB/H,EAAI+H,wBAEd,GAAEpG,KAAK1B,KACV,C","sources":["webpack://leaflet.extras/./inst/htmlwidgets/bindings/lfx-search-bindings.js"],"sourcesContent":["/* global $, LeafletWidget, L, Shiny, HTMLWidgets, google */\r\n\r\n// helper function to conver JS event to Shiny Event\r\nfunction eventToShiny(e) {\r\n var shinyEvent = {};\r\n shinyEvent.latlng = {};\r\n shinyEvent.latlng.lat = e.latlng.lat;\r\n shinyEvent.latlng.lng = e.latlng.lng;\r\n if(!$.isEmptyObject(e.title)) {\r\n shinyEvent.title = e.title;\r\n }\r\n if(!$.isEmptyObject(e.layer)) {\r\n shinyEvent.layer = e.layer.toGeoJSON();\r\n }\r\n return shinyEvent;\r\n}\r\n\r\nLeafletWidget.methods.addSearchOSM = function(options) {\r\n\r\n (function(){\r\n var map = this;\r\n\r\n if(map.searchControlOSM) {\r\n map.searchControlOSM.remove(map);\r\n delete map.searchControlOSM;\r\n }\r\n\r\n options = options || {};\r\n options.textPlaceholder = options.textPlaceholder ? options.textPlaceholder : 'Search using OSM Geocoder';\r\n options.url = options.url ? options.url : 'https://nominatim.openstreetmap.org/search?format=json&q={s}';\r\n options.jsonpParam = options.jsonpParam ? options.jsonpParam : 'json_callback';\r\n options.propertyName = options.propertyName ? options.propertyName : 'display_name';\r\n options.propertyLoc = options.propertyLoc ? options.propertyLoc : ['lat','lon'];\r\n\r\n // https://github.com/stefanocudini/leaflet-search/issues/129\r\n options.marker = L.circleMarker([0,0],{radius:30});\r\n\r\n if(options.moveToLocation) {\r\n options.moveToLocation = function(latlng, title, map) {\r\n var zoom = options.zoom || 16;\r\n var maxZoom = map.getMaxZoom();\r\n if(maxZoom && zoom > maxZoom) {\r\n zoom = maxZoom;\r\n }\r\n map.setView(latlng, zoom);\r\n };\r\n }\r\n\r\n map.searchControlOSM = new L.Control.Search(options);\r\n map.searchControlOSM.addTo(map);\r\n\r\n map.searchControlOSM.on('search:locationfound', function(e){\r\n // Shiny stuff\r\n if (!HTMLWidgets.shinyMode) return;\r\n Shiny.onInputChange(map.id+'_search_location_found', eventToShiny(e));\r\n });\r\n\r\n }).call(this);\r\n};\r\n\r\nvar clickOSMEventHandler;\r\nLeafletWidget.methods.removeSearchOSM = function() {\r\n (function(){\r\n var map = this;\r\n if(map.searchControlOSM) {\r\n map.searchControlOSM.remove(map);\r\n delete map.searchControlOSM;\r\n }\r\n var revsear = document.getElementById('reverseSearchOSM')\r\n if (revsear) {\r\n revsear.remove();\r\n map.off('click', clickOSMEventHandler);\r\n }\r\n }).call(this);\r\n};\r\n\r\nLeafletWidget.methods.addReverseSearchOSM = function(options, group) {\r\n (function() {\r\n\r\n var map = this;\r\n\r\n group = group || 'reverse_search_osm' ;\r\n map.layerManager.clearGroup(group);\r\n\r\n var displayControl = document.getElementById('reverseSearchOSM');\r\n\r\n var searchURL = 'https://nominatim.openstreetmap.org/reverse?format=json&polygon_geojson=1';\r\n\r\n clickOSMEventHandler = function(e){\r\n var latlng = e.latlng;\r\n\r\n // This will hold the query, boundingbox, and found feature layers\r\n var container = L.featureGroup();\r\n var layerID = L.stamp(container);\r\n\r\n if(options.showSearchLocation) {\r\n var marker = L.marker(e.latlng,{'type': 'query'}).bindTooltip(\r\n 'lat='+latlng.lat+' lng='+latlng.lng+'

');\r\n /* eslint-disable no-unused-vars */\r\n var m_layerID = L.stamp(marker);\r\n /* eslint-enable no-unused-vars */\r\n container.addLayer(marker);\r\n }\r\n\r\n var query = searchURL + '&lat=' + latlng.lat + '&lon=' + latlng.lng;\r\n\r\n $.ajax({url: query, dataType: 'json'}).done(function(result){\r\n // Check if the response contains an error\r\n if (result.error && result.error === \"Unable to geocode\") {\r\n displayControl.innerHTML = \"Unable to geocode\";\r\n return;\r\n }\r\n\r\n if(!$.isEmptyObject(displayControl)) {\r\n var displayText = '
';\r\n displayText = displayText + 'Display Name: ' +\r\n ( (result.display_name) ? result.display_name : '' ) + '
';\r\n displayText = displayText + '
';\r\n displayControl.innerHTML = displayText;\r\n }\r\n\r\n var bb = L.latLngBounds(\r\n L.latLng(result.boundingbox[0],result.boundingbox[2]),\r\n L.latLng(result.boundingbox[1], result.boundingbox[3]));\r\n\r\n if(options.showBounds) {\r\n var rect = L.rectangle(bb, {\r\n weight:2, color: '#444444', clickable: false,\r\n dashArray: '5,10', 'type': 'result_boundingbox'});\r\n /* eslint-disable no-unused-vars */\r\n var bb_layerID = L.stamp(rect);\r\n /* eslint-enable no-unused-vars */\r\n container.addLayer(rect);\r\n }\r\n\r\n if(options.showFeature) {\r\n var feature = L.geoJson(result.geojson,\r\n {\r\n weight:2, color: 'red', dashArray: '5,10',\r\n clickable : false, 'type': 'result_feature',\r\n pointToLayer: function(feature, latlng) {\r\n return L.circleMarker(latlng,{\r\n weight:2, color: 'red', dashArray: '5,10', clickable : false});\r\n }\r\n });\r\n\r\n /* eslint-disable no-unused-vars */\r\n var f_layerID = L.stamp(feature);\r\n /* eslint-enable no-unused-vars */\r\n container.addLayer(feature);\r\n }\r\n\r\n var tmp = container.getLayers();\r\n if(!$.isEmptyObject(tmp) && tmp.length >= 0) {\r\n\r\n if(!$.isEmptyObject(marker)) {\r\n marker.on('mouseover', function(e){\r\n if(!$.isEmptyObject(rect)) {\r\n rect.setStyle({fillOpacity: 0.5, opacity: 0.8, weight: 5});\r\n rect.bringToFront();\r\n }\r\n if(!$.isEmptyObject(feature)) {\r\n feature.setStyle({fillOpacity: 0.5, opacity: 0.8, weight: 5});\r\n feature.bringToFront();\r\n }\r\n });\r\n marker.on('mouseout', function(e){\r\n if(!$.isEmptyObject(rect)) {\r\n rect.setStyle({fillOpacity: 0.2, opacity: 0.5, weight: 2});\r\n rect.bringToBack();\r\n }\r\n if(!$.isEmptyObject(feature)) {\r\n feature.setStyle({fillOpacity: 0.2, opacity: 0.5, weight: 2});\r\n feature.bringToBack();\r\n }\r\n });\r\n }\r\n\r\n map.layerManager.addLayer(container, 'search', layerID, group);\r\n if(options.fitBounds)\r\n map.fitBounds(container.getBounds());\r\n }\r\n\r\n if (HTMLWidgets.shinyMode) {\r\n Shiny.onInputChange(map.id+'_reverse_search_feature_found',{\r\n 'query': {'lat': latlng.lat, 'lng': latlng.lng},\r\n 'result': result\r\n });\r\n }\r\n\r\n });\r\n }\r\n\r\n map.on('click', clickOSMEventHandler);\r\n\r\n }).call(this);\r\n};\r\n\r\n\r\nLeafletWidget.methods.searchOSMText = function(text) {\r\n (function(){\r\n var map = this;\r\n if(map.searchControlOSM) {\r\n map.searchControlOSM.searchText(text);\r\n }\r\n }).call(this);\r\n};\r\n\r\n\r\n\r\n\r\nLeafletWidget.methods.addSearchGoogle = function(options) {\r\n\r\n (function(){\r\n var map = this;\r\n\r\n if(map.searchControlGoogle) {\r\n map.searchControlGoogle.remove(map);\r\n delete map.searchControlGoogle;\r\n }\r\n\r\n var geocoder = new google.maps.Geocoder();\r\n\r\n function googleGeocoding(text, callResponse) {\r\n geocoder.geocode({address: text}, callResponse);\r\n }\r\n\r\n function formatJSON(rawjson) {\r\n var json = {},\r\n key, loc;\r\n\r\n for(var i in rawjson) {\r\n key = rawjson[i].formatted_address;\r\n loc = L.latLng( rawjson[i].geometry.location.lat(), rawjson[i].geometry.location.lng() );\r\n json[ key ]= loc; //key,value format\r\n }\r\n return json;\r\n }\r\n\r\n options = options || {};\r\n options.markerLocation = true;\r\n options.textPlaceholder = options.textPlaceholder ? options.textPlaceholder : 'Search using Google Geocoder';\r\n\r\n // https://github.com/stefanocudini/leaflet-search/issues/129\r\n options.marker = L.circleMarker([0,0],{radius:30});\r\n\r\n if(options.moveToLocation) {\r\n options.moveToLocation = function(latlng, title, map) {\r\n var zoom = options.zoom || 16;\r\n var maxZoom = map.getMaxZoom();\r\n if(maxZoom && zoom > maxZoom) {\r\n zoom = maxZoom;\r\n }\r\n map.setView(latlng, zoom);\r\n };\r\n }\r\n\r\n options.sourceData = googleGeocoding;\r\n options.formatData = formatJSON;\r\n\r\n map.searchControlGoogle = new L.Control.Search(options);\r\n map.searchControlGoogle.addTo(map);\r\n\r\n map.searchControlGoogle.on('search:locationfound', function(e){\r\n // Shiny stuff\r\n if (!HTMLWidgets.shinyMode) return;\r\n Shiny.onInputChange(map.id+'_search_location_found', eventToShiny(e));\r\n });\r\n\r\n }).call(this);\r\n};\r\n\r\nvar clickGOOEventHandler;\r\nLeafletWidget.methods.removeSearchGoogle = function() {\r\n (function(){\r\n var map = this;\r\n if(map.searchControlGoogle) {\r\n map.searchControlGoogle.remove(map);\r\n delete map.searchControlGoogle;\r\n }\r\n var revsear = document.getElementById('reverseSearchGoogle')\r\n if (revsear) {\r\n revsear.remove();\r\n map.off('click', clickGOOEventHandler);\r\n }\r\n }).call(this);\r\n};\r\n\r\nLeafletWidget.methods.addReverseSearchGoogle = function(options, group) {\r\n (function() {\r\n\r\n var map = this;\r\n\r\n group = group || 'reverse_search_google' ;\r\n map.layerManager.clearGroup(group);\r\n\r\n var displayControl = document.getElementById('reverseSearchGoogle');\r\n\r\n var geocoder = new google.maps.Geocoder();\r\n\r\n clickGOOEventHandler = function(e){\r\n var latlng = e.latlng;\r\n // This will hold the query, boundingbox, and found feature layers\r\n var container = L.featureGroup();\r\n var layerID = L.stamp(container);\r\n\r\n if(options.showSearchLocation) {\r\n var marker = L.marker(e.latlng,{'type': 'query'}).bindTooltip(\r\n 'lat='+latlng.lat+' lng='+latlng.lng+'

');\r\n /* eslint-disable no-unused-vars */\r\n var m_layerID = L.stamp(marker);\r\n /* eslint-enable no-unused-vars */\r\n container.addLayer(marker);\r\n }\r\n\r\n geocoder.geocode(\r\n {'location': {'lat': latlng.lat, 'lng': latlng.lng}},\r\n function(results, status) {\r\n\r\n if(status === 'OK') {\r\n if(results[0]) {\r\n var result = results[0];\r\n\r\n if(!$.isEmptyObject(displayControl)) {\r\n var displayText = '
';\r\n displayText = displayText + 'Address: ' +\r\n ( (result.formatted_address) ? result.formatted_address : '' ) + '
';\r\n displayText = displayText + '
';\r\n displayControl.innerHTML = displayText;\r\n }\r\n\r\n var bb = L.latLngBounds(\r\n L.latLng(result.geometry.viewport.f.f,\r\n result.geometry.viewport.b.b),\r\n L.latLng(result.geometry.viewport.f.b,\r\n result.geometry.viewport.b.f));\r\n\r\n if(options.showBounds) {\r\n var rect = L.rectangle(bb, {\r\n weight:2, color: '#444444', clickable: false,\r\n dashArray: '5,10', 'type': 'result_boundingbox'});\r\n /* eslint-disable no-unused-vars */\r\n var bb_layerID = L.stamp(rect);\r\n /* eslint-enable no-unused-vars */\r\n container.addLayer(rect);\r\n }\r\n\r\n if(options.showFeature) {\r\n var feature = L.circleMarker(\r\n L.latLng(\r\n result.geometry.location.lat(),\r\n result.geometry.location.lng()\r\n ), {\r\n weight:2, color: 'red', dashArray: '5,10',\r\n clickable : false, 'type': 'result_feature'\r\n }\r\n );\r\n\r\n /* eslint-disable no-unused-vars */\r\n var f_layerID = L.stamp(feature);\r\n /* eslint-disable no-unused-vars */\r\n container.addLayer(feature);\r\n }\r\n\r\n var tmp = container.getLayers();\r\n if(!$.isEmptyObject(tmp) && tmp.length >= 0) {\r\n\r\n if(!$.isEmptyObject(marker)) {\r\n marker.on('mouseover', function(e){\r\n if(!$.isEmptyObject(rect)) {\r\n rect.setStyle({fillOpacity: 0.5, opacity: 0.8, weight: 5});\r\n rect.bringToFront();\r\n }\r\n if(!$.isEmptyObject(feature)) {\r\n feature.setStyle({fillOpacity: 0.5, opacity: 0.8, weight: 5});\r\n feature.bringToFront();\r\n }\r\n });\r\n marker.on('mouseout', function(e){\r\n if(!$.isEmptyObject(rect)) {\r\n rect.setStyle({fillOpacity: 0.2, opacity: 0.5, weight: 2});\r\n rect.bringToBack();\r\n }\r\n if(!$.isEmptyObject(feature)) {\r\n feature.setStyle({fillOpacity: 0.2, opacity: 0.5, weight: 2});\r\n feature.bringToBack();\r\n }\r\n });\r\n }\r\n\r\n map.layerManager.addLayer(container, 'search', layerID, group);\r\n if(options.fitBounds)\r\n map.fitBounds(container.getBounds());\r\n }\r\n\r\n if (HTMLWidgets.shinyMode) {\r\n Shiny.onInputChange(map.id+'_reverse_search_feature_found',{\r\n 'query': {'lat': latlng.lat, 'lng': latlng.lng},\r\n 'result': result\r\n });\r\n }\r\n } else {\r\n if(!$.isEmptyObject(displayControl))\r\n displayControl.innerHTML = 'No Results Found';\r\n /* eslint-disable no-console */\r\n console.error('No Results Found');\r\n /* eslint-enable no-console */\r\n }\r\n } else {\r\n if(!$.isEmptyObject(displayControl))\r\n displayControl.innerHTML = 'Reverse Geocoding failed due to: ' + status;\r\n /* eslint-disable no-console */\r\n console.error('Reverse Geocoing failed due to: ' + status);\r\n /* eslint-enable no-console */\r\n }\r\n }\r\n );\r\n }\r\n\r\n map.on('click', clickGOOEventHandler)\r\n\r\n }).call(this);\r\n};\r\n\r\n\r\nLeafletWidget.methods.addSearchUSCensusBureau = function(options) {\r\n (function(){\r\n var map = this;\r\n\r\n if(map.searchControlUSCensusBureau) {\r\n map.searchControlUSCensusBureau.remove(map);\r\n delete map.searchControlUSCensusBureau;\r\n }\r\n\r\n function formatJSON(rawjson) {\r\n var json = {}, key, loc;\r\n\r\n for (var i in rawjson.result.addressMatches) {\r\n key = rawjson.result.addressMatches[i].matchedAddress;\r\n loc = L.latLng(rawjson.result.addressMatches[i].coordinates.y, rawjson.result.addressMatches[i].coordinates.x);\r\n json[key] = loc; //key,value format\r\n }\r\n return json;\r\n }\r\n\r\n options = options || {};\r\n\r\n options.url = options.url ? options.url : 'https://geocoding.geo.census.gov/geocoder/locations/onelineaddress?benchmark=Public_AR_Current&format=jsonp&address={s}';\r\n options.textPlaceholder = options.textPlaceholder ? options.textPlaceholder : 'Search using US Census Bureau TEST';\r\n\r\n options.jsonpParam = options.jsonpParam ? options.jsonpParam : 'callback';\r\n options.formatData = formatJSON;\r\n\r\n // https://github.com/stefanocudini/leaflet-search/issues/129\r\n options.marker = L.circleMarker([0,0],{radius:30});\r\n\r\n if(options.moveToLocation) {\r\n options.moveToLocation = function(latlng, title, map) {\r\n var zoom = options.zoom || 16;\r\n var maxZoom = map.getMaxZoom();\r\n if(maxZoom && zoom > maxZoom) {\r\n zoom = maxZoom;\r\n }\r\n map.setView(latlng, zoom);\r\n };\r\n }\r\n\r\n map.searchControlUSCensusBureau = new L.Control.Search(options);\r\n map.searchControlUSCensusBureau.addTo(map);\r\n\r\n map.searchControlUSCensusBureau.on('search:locationfound', function(e){\r\n // Shiny stuff\r\n if (!HTMLWidgets.shinyMode) return;\r\n Shiny.onInputChange(map.id+'_search_location_found', eventToShiny(e));\r\n });\r\n\r\n }).call(this);\r\n};\r\n\r\nLeafletWidget.methods.removeSearchUSCensusBureau = function() {\r\n (function(){\r\n var map = this;\r\n if (map.searchControlUSCensusBureau) {\r\n map.searchControlUSCensusBureau.remove(map);\r\n delete map.searchControlUSCensusBureau;\r\n }\r\n }).call(this);\r\n};\r\n\r\n\r\nLeafletWidget.methods.addSearchFeatures = function(targetGroups, options){\r\n (function(){\r\n var map = this;\r\n\r\n if(map.searchControl) {\r\n map.searchControl.remove(map);\r\n delete map.searchControl;\r\n }\r\n\r\n options = options || {};\r\n\r\n if(options.moveToLocation) {\r\n options.moveToLocation = function(latlng, title, map) {\r\n var zoom = options.zoom || 16;\r\n var maxZoom = map.getMaxZoom();\r\n if(maxZoom && zoom > maxZoom) {\r\n zoom = maxZoom;\r\n }\r\n map.setView(latlng, zoom);\r\n };\r\n }\r\n\r\n // FeatureGroup that will be searched\r\n var searchFeatureGroup;\r\n\r\n // if we have just one group to search use it.\r\n if(!L.Util.isArray(targetGroups)) {\r\n var target = map.layerManager.getLayerGroup(targetGroups, false);\r\n if(target) {\r\n searchFeatureGroup = target;\r\n map._searchFeatureGroupName = targetGroups;\r\n } else {\r\n // throw an error if we can't find the target FeatureGroup layer\r\n throw 'Group with ID \"'+targetGroups+'\" not found';\r\n }\r\n } else { // if we have more than one groups to search create a new seach group with them.\r\n\r\n searchFeatureGroup = map.layerManager.getLayerGroup('search', true);\r\n map._searchFeatureGroupName = 'search';\r\n\r\n $.each(targetGroups, function(k, v) {\r\n var target = map.layerManager.getLayerGroup(v, false);\r\n // may be remove target from map before adding to searchFeatureGroup\r\n if(target) {\r\n searchFeatureGroup.addLayer(target);\r\n } else {\r\n /* eslint-disable no-console */\r\n console.warn('Group with ID \"' + v + '\" not Found, skipping');\r\n /* eslint-enable no-console */\r\n }\r\n });\r\n }\r\n\r\n L.stamp(searchFeatureGroup);\r\n options.layer = searchFeatureGroup;\r\n map.searchControl = new L.Control.Search(options);\r\n map.searchControl.addTo(map);\r\n\r\n map.searchControl.on('search:locationfound', function(e){\r\n if(options.openPopup && e.layer._popup) {\r\n e.layer.openPopup();\r\n }\r\n // Shiny stuff\r\n if (!HTMLWidgets.shinyMode) return;\r\n Shiny.onInputChange(map.id+'_search_location_found', eventToShiny(e));\r\n });\r\n\r\n }).call(this);\r\n};\r\n\r\nLeafletWidget.methods.removeSearchFeatures = function(clearFeatures) {\r\n (function(){\r\n var map = this;\r\n if (map.searchControl) {\r\n map.searchControl.remove(map);\r\n delete map.searchControl;\r\n }\r\n if (clearFeatures && map._searchFeatureGroupName) {\r\n map.layerManager.clearGroup(map._searchFeatureGroupName);\r\n delete map._searchFeatureGroupName ;\r\n }\r\n }).call(this);\r\n};\r\n"],"names":["eventToShiny","e","shinyEvent","latlng","lat","lng","$","isEmptyObject","title","layer","toGeoJSON","clickOSMEventHandler","clickGOOEventHandler","LeafletWidget","methods","addSearchOSM","options","map","this","searchControlOSM","remove","textPlaceholder","url","jsonpParam","propertyName","propertyLoc","marker","L","circleMarker","radius","moveToLocation","zoom","maxZoom","getMaxZoom","setView","Control","Search","addTo","on","HTMLWidgets","shinyMode","Shiny","onInputChange","id","call","removeSearchOSM","revsear","document","getElementById","off","addReverseSearchOSM","group","layerManager","clearGroup","displayControl","container","featureGroup","layerID","stamp","showSearchLocation","bindTooltip","addLayer","query","searchURL","ajax","dataType","done","result","error","innerHTML","displayText","display_name","bb","latLngBounds","latLng","boundingbox","showBounds","rect","rectangle","weight","color","clickable","dashArray","showFeature","feature","geoJson","geojson","pointToLayer","tmp","getLayers","length","setStyle","fillOpacity","opacity","bringToFront","bringToBack","fitBounds","getBounds","searchOSMText","text","searchText","addSearchGoogle","searchControlGoogle","geocoder","google","maps","Geocoder","markerLocation","sourceData","callResponse","geocode","address","formatData","rawjson","key","loc","json","i","formatted_address","geometry","location","removeSearchGoogle","addReverseSearchGoogle","results","status","viewport","f","b","console","addSearchUSCensusBureau","searchControlUSCensusBureau","addressMatches","matchedAddress","coordinates","y","x","removeSearchUSCensusBureau","addSearchFeatures","targetGroups","searchFeatureGroup","searchControl","Util","isArray","getLayerGroup","_searchFeatureGroupName","each","k","v","target","warn","openPopup","_popup","removeSearchFeatures","clearFeatures"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"lfx-search-bindings.js","mappings":"MAGA,SAASA,EAAaC,GACpB,IAAIC,EAAa,CACjBA,OAAoB,CAAC,GASrB,OARAA,EAAWC,OAAOC,IAAMH,EAAEE,OAAOC,IACjCF,EAAWC,OAAOE,IAAMJ,EAAEE,OAAOE,IAC7BC,EAAEC,cAAcN,EAAEO,SACpBN,EAAWM,MAAQP,EAAEO,OAEnBF,EAAEC,cAAcN,EAAEQ,SACpBP,EAAWO,MAAQR,EAAEQ,MAAMC,aAEtBR,CACT,CA6CA,IAAIS,EAoNAC,EA/PJC,cAAcC,QAAQC,aAAe,SAASC,IAE5C,WACE,IAAIC,EAAMC,KAEPD,EAAIE,mBACLF,EAAIE,iBAAiBC,OAAOH,UACrBA,EAAIE,mBAGbH,EAAUA,GAAW,CAAC,GACdK,gBAAkBL,EAAQK,gBAAkBL,EA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K1B,KACV,EAEAL,cAAcC,QAAQ0I,qBAAuB,SAASC,IACpD,WACE,IAAIxI,EAAMC,KACND,EAAI2H,gBACN3H,EAAI2H,cAAcxH,OAAOH,UAClBA,EAAI2H,eAETa,GAAiBxI,EAAI+H,0BACvB/H,EAAImC,aAAaC,WAAWpC,EAAI+H,gCACzB/H,EAAI+H,wBAEd,GAAEpG,KAAK1B,KACV,C","sources":["webpack://leaflet.extras/./inst/htmlwidgets/bindings/lfx-search-bindings.js"],"sourcesContent":["/* global $, LeafletWidget, L, Shiny, HTMLWidgets, google */\r\n\r\n// helper function to conver JS event to Shiny Event\r\nfunction eventToShiny(e) {\r\n var shinyEvent = {};\r\n shinyEvent.latlng = {};\r\n shinyEvent.latlng.lat = e.latlng.lat;\r\n shinyEvent.latlng.lng = e.latlng.lng;\r\n if(!$.isEmptyObject(e.title)) {\r\n shinyEvent.title = e.title;\r\n }\r\n if(!$.isEmptyObject(e.layer)) {\r\n shinyEvent.layer = e.layer.toGeoJSON();\r\n }\r\n return shinyEvent;\r\n}\r\n\r\nLeafletWidget.methods.addSearchOSM = function(options) {\r\n\r\n (function(){\r\n var map = this;\r\n\r\n if(map.searchControlOSM) {\r\n map.searchControlOSM.remove(map);\r\n delete map.searchControlOSM;\r\n }\r\n\r\n options = options || {};\r\n options.textPlaceholder = options.textPlaceholder ? options.textPlaceholder : 'Search using OSM Geocoder';\r\n options.url = options.url ? options.url : 'https://nominatim.openstreetmap.org/search?format=json&q={s}';\r\n options.jsonpParam = options.jsonpParam ? options.jsonpParam : 'json_callback';\r\n options.propertyName = options.propertyName ? options.propertyName : 'display_name';\r\n options.propertyLoc = options.propertyLoc ? options.propertyLoc : ['lat','lon'];\r\n\r\n // https://github.com/stefanocudini/leaflet-search/issues/129\r\n options.marker = L.circleMarker([0,0],{radius:30});\r\n\r\n if(options.moveToLocation) {\r\n options.moveToLocation = function(latlng, title, map) {\r\n var zoom = options.zoom || 16;\r\n var maxZoom = map.getMaxZoom();\r\n if(maxZoom && zoom > maxZoom) {\r\n zoom = maxZoom;\r\n }\r\n map.setView(latlng, zoom);\r\n };\r\n }\r\n\r\n map.searchControlOSM = new L.Control.Search(options);\r\n map.searchControlOSM.addTo(map);\r\n\r\n map.searchControlOSM.on('search:locationfound', function(e){\r\n // Shiny stuff\r\n if (!HTMLWidgets.shinyMode) return;\r\n Shiny.onInputChange(map.id+'_search_location_found', eventToShiny(e));\r\n });\r\n\r\n }).call(this);\r\n};\r\n\r\nvar clickOSMEventHandler;\r\nLeafletWidget.methods.removeSearchOSM = function() {\r\n (function(){\r\n var map = this;\r\n if(map.searchControlOSM) {\r\n map.searchControlOSM.remove(map);\r\n delete map.searchControlOSM;\r\n }\r\n var revsear = document.getElementById('reverseSearchOSM');\r\n if (revsear) {\r\n revsear.remove();\r\n map.off('click', clickOSMEventHandler);\r\n }\r\n }).call(this);\r\n};\r\n\r\nLeafletWidget.methods.addReverseSearchOSM = function(options, group) {\r\n (function() {\r\n\r\n var map = this;\r\n\r\n group = group || 'reverse_search_osm' ;\r\n map.layerManager.clearGroup(group);\r\n\r\n var displayControl = document.getElementById('reverseSearchOSM');\r\n\r\n var searchURL = 'https://nominatim.openstreetmap.org/reverse?format=json&polygon_geojson=1';\r\n\r\n clickOSMEventHandler = function(e){\r\n var latlng = e.latlng;\r\n\r\n // This will hold the query, boundingbox, and found feature layers\r\n var container = L.featureGroup();\r\n var layerID = L.stamp(container);\r\n\r\n if(options.showSearchLocation) {\r\n var marker = L.marker(e.latlng,{'type': 'query'}).bindTooltip(\r\n 'lat='+latlng.lat+' lng='+latlng.lng+'

');\r\n /* eslint-disable no-unused-vars */\r\n var m_layerID = L.stamp(marker);\r\n /* eslint-enable no-unused-vars */\r\n container.addLayer(marker);\r\n }\r\n\r\n var query = searchURL + '&lat=' + latlng.lat + '&lon=' + latlng.lng;\r\n\r\n $.ajax({url: query, dataType: 'json'}).done(function(result){\r\n // Check if the response contains an error\r\n if (result.error && result.error === 'Unable to geocode') {\r\n displayControl.innerHTML = 'Unable to geocode';\r\n return;\r\n }\r\n\r\n if(!$.isEmptyObject(displayControl)) {\r\n var displayText = '
';\r\n displayText = displayText + 'Display Name: ' +\r\n ( (result.display_name) ? result.display_name : '' ) + '
';\r\n displayText = displayText + '
';\r\n displayControl.innerHTML = displayText;\r\n }\r\n\r\n var bb = L.latLngBounds(\r\n L.latLng(result.boundingbox[0],result.boundingbox[2]),\r\n L.latLng(result.boundingbox[1], result.boundingbox[3]));\r\n\r\n if(options.showBounds) {\r\n var rect = L.rectangle(bb, {\r\n weight:2, color: '#444444', clickable: false,\r\n dashArray: '5,10', 'type': 'result_boundingbox'});\r\n /* eslint-disable no-unused-vars */\r\n var bb_layerID = L.stamp(rect);\r\n /* eslint-enable no-unused-vars */\r\n container.addLayer(rect);\r\n }\r\n\r\n if(options.showFeature) {\r\n var feature = L.geoJson(result.geojson,\r\n {\r\n weight:2, color: 'red', dashArray: '5,10',\r\n clickable : false, 'type': 'result_feature',\r\n pointToLayer: function(feature, latlng) {\r\n return L.circleMarker(latlng,{\r\n weight:2, color: 'red', dashArray: '5,10', clickable : false});\r\n }\r\n });\r\n\r\n /* eslint-disable no-unused-vars */\r\n var f_layerID = L.stamp(feature);\r\n /* eslint-enable no-unused-vars */\r\n container.addLayer(feature);\r\n }\r\n\r\n var tmp = container.getLayers();\r\n if(!$.isEmptyObject(tmp) && tmp.length >= 0) {\r\n\r\n if(!$.isEmptyObject(marker)) {\r\n marker.on('mouseover', function(){\r\n if(!$.isEmptyObject(rect)) {\r\n rect.setStyle({fillOpacity: 0.5, opacity: 0.8, weight: 5});\r\n rect.bringToFront();\r\n }\r\n if(!$.isEmptyObject(feature)) {\r\n feature.setStyle({fillOpacity: 0.5, opacity: 0.8, weight: 5});\r\n feature.bringToFront();\r\n }\r\n });\r\n marker.on('mouseout', function(){\r\n if(!$.isEmptyObject(rect)) {\r\n rect.setStyle({fillOpacity: 0.2, opacity: 0.5, weight: 2});\r\n rect.bringToBack();\r\n }\r\n if(!$.isEmptyObject(feature)) {\r\n feature.setStyle({fillOpacity: 0.2, opacity: 0.5, weight: 2});\r\n feature.bringToBack();\r\n }\r\n });\r\n }\r\n\r\n map.layerManager.addLayer(container, 'search', layerID, group);\r\n if(options.fitBounds)\r\n map.fitBounds(container.getBounds());\r\n }\r\n\r\n if (HTMLWidgets.shinyMode) {\r\n Shiny.onInputChange(map.id+'_reverse_search_feature_found',{\r\n 'query': {'lat': latlng.lat, 'lng': latlng.lng},\r\n 'result': result\r\n });\r\n }\r\n\r\n });\r\n };\r\n\r\n map.on('click', clickOSMEventHandler);\r\n\r\n }).call(this);\r\n};\r\n\r\n\r\nLeafletWidget.methods.searchOSMText = function(text) {\r\n (function(){\r\n var map = this;\r\n if(map.searchControlOSM) {\r\n map.searchControlOSM.searchText(text);\r\n }\r\n }).call(this);\r\n};\r\n\r\n\r\n\r\n\r\nLeafletWidget.methods.addSearchGoogle = function(options) {\r\n\r\n (function(){\r\n var map = this;\r\n\r\n if(map.searchControlGoogle) {\r\n map.searchControlGoogle.remove(map);\r\n delete map.searchControlGoogle;\r\n }\r\n\r\n var geocoder = new google.maps.Geocoder();\r\n\r\n function googleGeocoding(text, callResponse) {\r\n geocoder.geocode({address: text}, callResponse);\r\n }\r\n\r\n function formatJSON(rawjson) {\r\n var json = {},\r\n key, loc;\r\n\r\n for(var i in rawjson) {\r\n key = rawjson[i].formatted_address;\r\n loc = L.latLng( rawjson[i].geometry.location.lat(), rawjson[i].geometry.location.lng() );\r\n json[ key ]= loc; //key,value format\r\n }\r\n return json;\r\n }\r\n\r\n options = options || {};\r\n options.markerLocation = true;\r\n options.textPlaceholder = options.textPlaceholder ? options.textPlaceholder : 'Search using Google Geocoder';\r\n\r\n // https://github.com/stefanocudini/leaflet-search/issues/129\r\n options.marker = L.circleMarker([0,0],{radius:30});\r\n\r\n if(options.moveToLocation) {\r\n options.moveToLocation = function(latlng, title, map) {\r\n var zoom = options.zoom || 16;\r\n var maxZoom = map.getMaxZoom();\r\n if(maxZoom && zoom > maxZoom) {\r\n zoom = maxZoom;\r\n }\r\n map.setView(latlng, zoom);\r\n };\r\n }\r\n\r\n options.sourceData = googleGeocoding;\r\n options.formatData = formatJSON;\r\n\r\n map.searchControlGoogle = new L.Control.Search(options);\r\n map.searchControlGoogle.addTo(map);\r\n\r\n map.searchControlGoogle.on('search:locationfound', function(e){\r\n // Shiny stuff\r\n if (!HTMLWidgets.shinyMode) return;\r\n Shiny.onInputChange(map.id+'_search_location_found', eventToShiny(e));\r\n });\r\n\r\n }).call(this);\r\n};\r\n\r\nvar clickGOOEventHandler;\r\nLeafletWidget.methods.removeSearchGoogle = function() {\r\n (function(){\r\n var map = this;\r\n if(map.searchControlGoogle) {\r\n map.searchControlGoogle.remove(map);\r\n delete map.searchControlGoogle;\r\n }\r\n var revsear = document.getElementById('reverseSearchGoogle');\r\n if (revsear) {\r\n revsear.remove();\r\n map.off('click', clickGOOEventHandler);\r\n }\r\n }).call(this);\r\n};\r\n\r\nLeafletWidget.methods.addReverseSearchGoogle = function(options, group) {\r\n (function() {\r\n\r\n var map = this;\r\n\r\n group = group || 'reverse_search_google' ;\r\n map.layerManager.clearGroup(group);\r\n\r\n var displayControl = document.getElementById('reverseSearchGoogle');\r\n\r\n var geocoder = new google.maps.Geocoder();\r\n\r\n clickGOOEventHandler = function(e){\r\n var latlng = e.latlng;\r\n // This will hold the query, boundingbox, and found feature layers\r\n var container = L.featureGroup();\r\n var layerID = L.stamp(container);\r\n\r\n if(options.showSearchLocation) {\r\n var marker = L.marker(e.latlng,{'type': 'query'}).bindTooltip(\r\n 'lat='+latlng.lat+' lng='+latlng.lng+'

');\r\n /* eslint-disable no-unused-vars */\r\n var m_layerID = L.stamp(marker);\r\n /* eslint-enable no-unused-vars */\r\n container.addLayer(marker);\r\n }\r\n\r\n geocoder.geocode(\r\n {'location': {'lat': latlng.lat, 'lng': latlng.lng}},\r\n function(results, status) {\r\n\r\n if(status === 'OK') {\r\n if(results[0]) {\r\n var result = results[0];\r\n\r\n if(!$.isEmptyObject(displayControl)) {\r\n var displayText = '
';\r\n displayText = displayText + 'Address: ' +\r\n ( (result.formatted_address) ? result.formatted_address : '' ) + '
';\r\n displayText = displayText + '
';\r\n displayControl.innerHTML = displayText;\r\n }\r\n\r\n var bb = L.latLngBounds(\r\n L.latLng(result.geometry.viewport.f.f,\r\n result.geometry.viewport.b.b),\r\n L.latLng(result.geometry.viewport.f.b,\r\n result.geometry.viewport.b.f));\r\n\r\n if(options.showBounds) {\r\n var rect = L.rectangle(bb, {\r\n weight:2, color: '#444444', clickable: false,\r\n dashArray: '5,10', 'type': 'result_boundingbox'});\r\n /* eslint-disable no-unused-vars */\r\n var bb_layerID = L.stamp(rect);\r\n /* eslint-enable no-unused-vars */\r\n container.addLayer(rect);\r\n }\r\n\r\n if(options.showFeature) {\r\n var feature = L.circleMarker(\r\n L.latLng(\r\n result.geometry.location.lat(),\r\n result.geometry.location.lng()\r\n ), {\r\n weight:2, color: 'red', dashArray: '5,10',\r\n clickable : false, 'type': 'result_feature'\r\n }\r\n );\r\n\r\n /* eslint-disable no-unused-vars */\r\n var f_layerID = L.stamp(feature);\r\n /* eslint-disable no-unused-vars */\r\n container.addLayer(feature);\r\n }\r\n\r\n var tmp = container.getLayers();\r\n if(!$.isEmptyObject(tmp) && tmp.length >= 0) {\r\n\r\n if(!$.isEmptyObject(marker)) {\r\n marker.on('mouseover', function(e){\r\n if(!$.isEmptyObject(rect)) {\r\n rect.setStyle({fillOpacity: 0.5, opacity: 0.8, weight: 5});\r\n rect.bringToFront();\r\n }\r\n if(!$.isEmptyObject(feature)) {\r\n feature.setStyle({fillOpacity: 0.5, opacity: 0.8, weight: 5});\r\n feature.bringToFront();\r\n }\r\n });\r\n marker.on('mouseout', function(e){\r\n if(!$.isEmptyObject(rect)) {\r\n rect.setStyle({fillOpacity: 0.2, opacity: 0.5, weight: 2});\r\n rect.bringToBack();\r\n }\r\n if(!$.isEmptyObject(feature)) {\r\n feature.setStyle({fillOpacity: 0.2, opacity: 0.5, weight: 2});\r\n feature.bringToBack();\r\n }\r\n });\r\n }\r\n\r\n map.layerManager.addLayer(container, 'search', layerID, group);\r\n if(options.fitBounds)\r\n map.fitBounds(container.getBounds());\r\n }\r\n\r\n if (HTMLWidgets.shinyMode) {\r\n Shiny.onInputChange(map.id+'_reverse_search_feature_found',{\r\n 'query': {'lat': latlng.lat, 'lng': latlng.lng},\r\n 'result': result\r\n });\r\n }\r\n } else {\r\n if(!$.isEmptyObject(displayControl))\r\n displayControl.innerHTML = 'No Results Found';\r\n /* eslint-disable no-console */\r\n console.error('No Results Found');\r\n /* eslint-enable no-console */\r\n }\r\n } else {\r\n if(!$.isEmptyObject(displayControl))\r\n displayControl.innerHTML = 'Reverse Geocoding failed due to: ' + status;\r\n /* eslint-disable no-console */\r\n console.error('Reverse Geocoing failed due to: ' + status);\r\n /* eslint-enable no-console */\r\n }\r\n }\r\n );\r\n };\r\n\r\n map.on('click', clickGOOEventHandler);\r\n\r\n }).call(this);\r\n};\r\n\r\n\r\nLeafletWidget.methods.addSearchUSCensusBureau = function(options) {\r\n (function(){\r\n var map = this;\r\n\r\n if(map.searchControlUSCensusBureau) {\r\n map.searchControlUSCensusBureau.remove(map);\r\n delete map.searchControlUSCensusBureau;\r\n }\r\n\r\n function formatJSON(rawjson) {\r\n var json = {}, key, loc;\r\n\r\n for (var i in rawjson.result.addressMatches) {\r\n key = rawjson.result.addressMatches[i].matchedAddress;\r\n loc = L.latLng(rawjson.result.addressMatches[i].coordinates.y, rawjson.result.addressMatches[i].coordinates.x);\r\n json[key] = loc; //key,value format\r\n }\r\n return json;\r\n }\r\n\r\n options = options || {};\r\n\r\n options.url = options.url ? options.url : 'https://geocoding.geo.census.gov/geocoder/locations/onelineaddress?benchmark=Public_AR_Current&format=jsonp&address={s}';\r\n options.textPlaceholder = options.textPlaceholder ? options.textPlaceholder : 'Search using US Census Bureau TEST';\r\n\r\n options.jsonpParam = options.jsonpParam ? options.jsonpParam : 'callback';\r\n options.formatData = formatJSON;\r\n\r\n // https://github.com/stefanocudini/leaflet-search/issues/129\r\n options.marker = L.circleMarker([0,0],{radius:30});\r\n\r\n if(options.moveToLocation) {\r\n options.moveToLocation = function(latlng, title, map) {\r\n var zoom = options.zoom || 16;\r\n var maxZoom = map.getMaxZoom();\r\n if(maxZoom && zoom > maxZoom) {\r\n zoom = maxZoom;\r\n }\r\n map.setView(latlng, zoom);\r\n };\r\n }\r\n\r\n map.searchControlUSCensusBureau = new L.Control.Search(options);\r\n map.searchControlUSCensusBureau.addTo(map);\r\n\r\n map.searchControlUSCensusBureau.on('search:locationfound', function(e){\r\n // Shiny stuff\r\n if (!HTMLWidgets.shinyMode) return;\r\n Shiny.onInputChange(map.id+'_search_location_found', eventToShiny(e));\r\n });\r\n\r\n }).call(this);\r\n};\r\n\r\nLeafletWidget.methods.removeSearchUSCensusBureau = function() {\r\n (function(){\r\n var map = this;\r\n if (map.searchControlUSCensusBureau) {\r\n map.searchControlUSCensusBureau.remove(map);\r\n delete map.searchControlUSCensusBureau;\r\n }\r\n }).call(this);\r\n};\r\n\r\n\r\nLeafletWidget.methods.addSearchFeatures = function(targetGroups, options){\r\n (function(){\r\n var map = this;\r\n\r\n if(map.searchControl) {\r\n map.searchControl.remove(map);\r\n delete map.searchControl;\r\n }\r\n\r\n options = options || {};\r\n\r\n if(options.moveToLocation) {\r\n options.moveToLocation = function(latlng, title, map) {\r\n var zoom = options.zoom || 16;\r\n var maxZoom = map.getMaxZoom();\r\n if(maxZoom && zoom > maxZoom) {\r\n zoom = maxZoom;\r\n }\r\n map.setView(latlng, zoom);\r\n };\r\n }\r\n\r\n // FeatureGroup that will be searched\r\n var searchFeatureGroup;\r\n\r\n // if we have just one group to search use it.\r\n if(!L.Util.isArray(targetGroups)) {\r\n var target = map.layerManager.getLayerGroup(targetGroups, false);\r\n if(target) {\r\n searchFeatureGroup = target;\r\n map._searchFeatureGroupName = targetGroups;\r\n } else {\r\n // throw an error if we can't find the target FeatureGroup layer\r\n throw 'Group with ID \"'+targetGroups+'\" not found';\r\n }\r\n } else { // if we have more than one groups to search create a new seach group with them.\r\n\r\n searchFeatureGroup = map.layerManager.getLayerGroup('search', true);\r\n map._searchFeatureGroupName = 'search';\r\n\r\n $.each(targetGroups, function(k, v) {\r\n var target = map.layerManager.getLayerGroup(v, false);\r\n // may be remove target from map before adding to searchFeatureGroup\r\n if(target) {\r\n searchFeatureGroup.addLayer(target);\r\n } else {\r\n /* eslint-disable no-console */\r\n console.warn('Group with ID \"' + v + '\" not Found, skipping');\r\n /* eslint-enable no-console */\r\n }\r\n });\r\n }\r\n\r\n L.stamp(searchFeatureGroup);\r\n options.layer = searchFeatureGroup;\r\n map.searchControl = new L.Control.Search(options);\r\n map.searchControl.addTo(map);\r\n\r\n map.searchControl.on('search:locationfound', function(e){\r\n if(options.openPopup && e.layer._popup) {\r\n e.layer.openPopup();\r\n }\r\n // Shiny stuff\r\n if (!HTMLWidgets.shinyMode) return;\r\n Shiny.onInputChange(map.id+'_search_location_found', eventToShiny(e));\r\n });\r\n\r\n }).call(this);\r\n};\r\n\r\nLeafletWidget.methods.removeSearchFeatures = function(clearFeatures) {\r\n (function(){\r\n var map = this;\r\n if (map.searchControl) {\r\n map.searchControl.remove(map);\r\n delete map.searchControl;\r\n }\r\n if (clearFeatures && map._searchFeatureGroupName) {\r\n map.layerManager.clearGroup(map._searchFeatureGroupName);\r\n delete map._searchFeatureGroupName ;\r\n }\r\n }).call(this);\r\n};\r\n"],"names":["eventToShiny","e","shinyEvent","latlng","lat","lng","$","isEmptyObject","title","layer","toGeoJSON","clickOSMEventHandler","clickGOOEventHandler","LeafletWidget","methods","addSearchOSM","options","map","this","searchControlOSM","remove","textPlaceholder","url","jsonpParam","propertyName","propertyLoc","marker","L","circleMarker","radius","moveToLocation","zoom","maxZoom","getMaxZoom","setView","Control","Search","addTo","on","HTMLWidgets","shinyMode","Shiny","onInputChange","id","call","removeSearchOSM","revsear","document","getElementById","off","addReverseSearchOSM","group","layerManager","clearGroup","displayControl","container","featureGroup","layerID","stamp","showSearchLocation","bindTooltip","addLayer","query","searchURL","ajax","dataType","done","result","error","innerHTML","displayText","display_name","bb","latLngBounds","latLng","boundingbox","showBounds","rect","rectangle","weight","color","clickable","dashArray","showFeature","feature","geoJson","geojson","pointToLayer","tmp","getLayers","length","setStyle","fillOpacity","opacity","bringToFront","bringToBack","fitBounds","getBounds","searchOSMText","text","searchText","addSearchGoogle","searchControlGoogle","geocoder","google","maps","Geocoder","markerLocation","sourceData","callResponse","geocode","address","formatData","rawjson","key","loc","json","i","formatted_address","geometry","location","removeSearchGoogle","addReverseSearchGoogle","results","status","viewport","f","b","console","addSearchUSCensusBureau","searchControlUSCensusBureau","addressMatches","matchedAddress","coordinates","y","x","removeSearchUSCensusBureau","addSearchFeatures","targetGroups","searchFeatureGroup","searchControl","Util","isArray","getLayerGroup","_searchFeatureGroupName","each","k","v","target","warn","openPopup","_popup","removeSearchFeatures","clearFeatures"],"sourceRoot":""} \ No newline at end of file diff --git a/inst/htmlwidgets/build/lfx-wms-legend/lfx-wms-legend-bindings.js.map b/inst/htmlwidgets/build/lfx-wms-legend/lfx-wms-legend-bindings.js.map index b05e2e84..2795e956 100644 --- a/inst/htmlwidgets/build/lfx-wms-legend/lfx-wms-legend-bindings.js.map +++ b/inst/htmlwidgets/build/lfx-wms-legend/lfx-wms-legend-bindings.js.map @@ -1 +1 @@ -{"version":3,"file":"lfx-wms-legend-bindings.js","mappings":"AACAA,cAAcC,QAAQC,cAAgB,SAASC,IAC7C,WACI,IACIC,EAAmB,IAAIC,EAAEC,QAAQC,UAAUJ,EAAQA,SACnDA,EAAQK,QAFFC,KAGJC,SAASC,IAAIP,EAAkBD,EAAQK,SAHnCC,KAKJC,SAASC,IAAIP,EAEtB,GAAEQ,KAAKH,KACV","sources":["webpack://leaflet.extras/./inst/htmlwidgets/bindings/lfx-wms-legend-bindings.js"],"sourcesContent":["/* global LeafletWidget, L */\r\nLeafletWidget.methods.addWMSLegend1 = function(options) {\r\n (function(){\r\n var map = this;\r\n var wmsLegendControl = new L.Control.WMSLegend(options.options);\r\n if (options.layerId) {\r\n map.controls.add(wmsLegendControl, options.layerId);\r\n } else {\r\n map.controls.add(wmsLegendControl);\r\n }\r\n }).call(this);\r\n};\r\n"],"names":["LeafletWidget","methods","addWMSLegend1","options","wmsLegendControl","L","Control","WMSLegend","layerId","this","controls","add","call"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"lfx-wms-legend-bindings.js","mappings":"AACAA,cAAcC,QAAQC,cAAgB,SAASC,IAC7C,WACE,IACIC,EAAmB,IAAIC,EAAEC,QAAQC,UAAUJ,EAAQA,SACnDA,EAAQK,QAFFC,KAGJC,SAASC,IAAIP,EAAkBD,EAAQK,SAHnCC,KAKJC,SAASC,IAAIP,EAEpB,GAAEQ,KAAKH,KACV","sources":["webpack://leaflet.extras/./inst/htmlwidgets/bindings/lfx-wms-legend-bindings.js"],"sourcesContent":["/* global LeafletWidget, L */\r\nLeafletWidget.methods.addWMSLegend1 = function(options) {\r\n (function(){\r\n var map = this;\r\n var wmsLegendControl = new L.Control.WMSLegend(options.options);\r\n if (options.layerId) {\r\n map.controls.add(wmsLegendControl, options.layerId);\r\n } else {\r\n map.controls.add(wmsLegendControl);\r\n }\r\n }).call(this);\r\n};\r\n"],"names":["LeafletWidget","methods","addWMSLegend1","options","wmsLegendControl","L","Control","WMSLegend","layerId","this","controls","add","call"],"sourceRoot":""} \ No newline at end of file diff --git a/package.json b/package.json index 31035399..d045a91b 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,8 @@ "private": true, "scripts": { "napa": "napa", - "build": "napa && webpack --config webpack.config.js", + "lint": "eslint ./inst/htmlwidgets/bindings --ext .js --fix", + "build": "npm run lint && napa && webpack --config webpack.config.js", "watch": "napa && webpack --config webpack.config.js --watch --progress", "test": "echo \"Error: no test specified\" && exit 1" }, diff --git a/webpack.config.js b/webpack.config.js index 17fbe0aa..8f07aac6 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -93,7 +93,7 @@ let library_binding = function(name) { // Specify the files/paths to lint. files: binding_path + name + "-bindings.js", // If you have an ESLint configuration file at a custom path, you can specify it here: - context: path.resolve(__dirname, 'inst/htmlwidgets/bindings/.eslintrc.js'), + context: path.resolve(__dirname, '.eslintrc.js'), }), ], // save bindings to build bindings folder