diff --git a/R/glify-helpers.R b/R/glify-helpers.R index 5e33ad0..9b42feb 100644 --- a/R/glify-helpers.R +++ b/R/glify-helpers.R @@ -6,7 +6,8 @@ glifyDependencies = function() { '3.2.0', system.file("htmlwidgets/Leaflet.glify", package = "leafgl"), script = c( - "addGlifyPoints.js" + "GlifyUtils.js" + , "addGlifyPoints.js" , "addGlifyPolygons.js" , "addGlifyPolylines.js" , "glify-browser.js" @@ -23,7 +24,8 @@ glifyDependenciesSrc = function() { '3.2.0', system.file("htmlwidgets/Leaflet.glify", package = "leafgl"), script = c( - "addGlifyPointsSrc.js" + "GlifyUtils.js" + , "addGlifyPointsSrc.js" , "addGlifyPolygonsSrc.js" , "addGlifyPolylinesSrc.js" , "glify-browser.js" diff --git a/inst/htmlwidgets/Leaflet.glify/GlifyUtils.js b/inst/htmlwidgets/Leaflet.glify/GlifyUtils.js new file mode 100644 index 0000000..6c8ae4b --- /dev/null +++ b/inst/htmlwidgets/Leaflet.glify/GlifyUtils.js @@ -0,0 +1,15 @@ +LeafletWidget.methods.clearGlLayers = function() { + this.layerManager.clearLayers("glify"); +}; + +LeafletWidget.methods.removeGlPolygons = function(layerId) { + this.layerManager.removeLayer("glify", layerId); +}; + +LeafletWidget.methods.removeGlPolylines = function(layerId) { + this.layerManager.removeLayer("glify", layerId); +}; + +LeafletWidget.methods.removeGlPoints = function(layerId) { + this.layerManager.removeLayer("glify", layerId); +}; diff --git a/inst/htmlwidgets/Leaflet.glify/addGlifyPoints.js b/inst/htmlwidgets/Leaflet.glify/addGlifyPoints.js index 9cc6325..287a45c 100644 --- a/inst/htmlwidgets/Leaflet.glify/addGlifyPoints.js +++ b/inst/htmlwidgets/Leaflet.glify/addGlifyPoints.js @@ -92,12 +92,3 @@ LeafletWidget.methods.addGlifyPoints = function(data, cols, popup, label, opacit // add layer to map using RStudio leaflet's layerManager map.layerManager.addLayer(pointslayer.layer, "glify", layerId, group); }; - - -LeafletWidget.methods.removeGlPoints = function(layerId) { - this.layerManager.removeLayer("glify", layerId); -}; - -LeafletWidget.methods.clearGlLayers = function() { - this.layerManager.clearLayers("glify"); -}; \ No newline at end of file diff --git a/inst/htmlwidgets/Leaflet.glify/addGlifyPolygons.js b/inst/htmlwidgets/Leaflet.glify/addGlifyPolygons.js index 71116dc..4ed919a 100644 --- a/inst/htmlwidgets/Leaflet.glify/addGlifyPolygons.js +++ b/inst/htmlwidgets/Leaflet.glify/addGlifyPolygons.js @@ -70,25 +70,3 @@ LeafletWidget.methods.addGlifyPolygons = function(data, cols, popup, label, opac map.layerManager.addLayer(shapeslayer.layer, "glify", layerId, group); }; - - -LeafletWidget.methods.removeGlPolygons = function(layerId) { - this.layerManager.removeLayer("glify", layerId); -}; - - - -function json2table(json, cls) { - var cols = Object.keys(json); - var vals = Object.values(json); - - var tab = ""; - - for (let i = 0; i < cols.length; i++) { - tab += "" + cols[i] + " " + - "" + vals[i] + " "; - } - - return "" + tab + "
"; - -} diff --git a/inst/htmlwidgets/Leaflet.glify/addGlifyPolylines.js b/inst/htmlwidgets/Leaflet.glify/addGlifyPolylines.js index 3e58f03..d0cfd45 100644 --- a/inst/htmlwidgets/Leaflet.glify/addGlifyPolylines.js +++ b/inst/htmlwidgets/Leaflet.glify/addGlifyPolylines.js @@ -80,7 +80,4 @@ LeafletWidget.methods.addGlifyPolylines = function(data, cols, popup, label, opa }; -LeafletWidget.methods.removeGlPolylines = function(layerId) { - this.layerManager.removeLayer("glify", layerId); -};