Skip to content

Fix labels/border/remove/clear-instances, **Src-functions, etc.. #95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
88ea86c
add args popup/labelOptions, fix labels, add dotlist to glify (sensit…
trafficonese Jun 3, 2024
ca4213a
move JS helper functions to sep file use const/let
trafficonese Jun 3, 2024
a100d37
fix remove/clear methods by layerId/group/all Glify, expose new metho…
trafficonese Jun 5, 2024
1135858
fix: allow layerId to be formula
trafficonese Jun 5, 2024
e6dbde3
move imports to separate pkg-file
trafficonese Jun 5, 2024
806bb8f
fix labels/popup for *Src functions, move Point click/Hover Functions…
trafficonese Jun 8, 2024
c5c9f37
convert_to_json function to try yyjsonr::write_json_str or jsonify::t…
trafficonese Jun 8, 2024
efb51c0
simplify/unify dependency calls
trafficonese Jun 8, 2024
1e95b55
allow custom json_parser_function
trafficonese Jun 8, 2024
706e10e
fixed hoverwait: 10, docs
trafficonese Jun 9, 2024
c3c3a97
use yyjsonr for geojson, expose new option "leafgl_geojson_parser"
trafficonese Jun 11, 2024
b509362
use yyjonsr instead of jsonify/geojsonsf, use correct options, fix te…
trafficonese Jun 11, 2024
af381dd
update Glify to 3.3.0, remove arr.splice workaround, remove tooltip i…
trafficonese Jun 22, 2024
3e9d39c
hoveroff_event JS-func, use .nonce to trigger event
trafficonese Jun 23, 2024
f978f87
Merge branch 'master' into fixlabels
trafficonese Nov 29, 2024
b8691d4
update Glify,update Roxygen, fix .Rproj error
trafficonese Jan 8, 2025
b064140
pull
trafficonese Jan 8, 2025
f2bb497
use Leaflet.Glify 3.3.1
trafficonese Apr 5, 2025
0cccb13
chore: use gha v4
trafficonese Apr 5, 2025
6a6a223
chore: use gha v4 for upload
trafficonese Apr 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
Expand Down Expand Up @@ -44,7 +44,7 @@ jobs:

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ Authors@R:
Description: Provides bindings to the 'Leaflet.glify' JavaScript library which extends the 'leaflet' JavaScript library to render large data in the browser using 'WebGl'.
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: false
RoxygenNote: 7.3.2
Imports:
geojsonsf,
htmltools,
jsonify,
leaflet,
sf,
yyjsonr,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should make things faster.

grDevices
Suggests:
colourvalues,
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ S3method(makePopup,shiny.tag)
export(addGlPoints)
export(addGlPolygons)
export(addGlPolylines)
export(clearGlGroup)
export(clearGlLayers)
export(leafglOutput)
export(makeColorMatrix)
Expand All @@ -37,5 +38,6 @@ export(renderLeafgl)
importFrom(htmltools,htmlDependencies)
importFrom(htmltools,tagList)
importFrom(htmltools,tags)
importFrom(leaflet,evalFormula)
importFrom(leaflet,leafletOutput)
importFrom(leaflet,renderLeaflet)
26 changes: 25 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
@@ -1,8 +1,32 @@
leafgl development-version

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


* Added some @details for Shiny click and mouseover events and their corresponding input. #77
* Use `@inheritParams leaflet::**` for identical function arguments

miscellaneous

* update upstream javascript dependency to 3.3.1. #49
Note: If you previously used the workaround `L.glify.Shapes.instances.splice(0, 1)`, please remove it with this new version.
* unified / simplified the dependency functions/calls


leafgl 0.2.2 (2024-11-13)

* Switched from `jsonify` and `geojsonsf` to `yyjsonr`
* New method *clearGlGroup* removes a group from leaflet and the Leaflet.Glify instances.
* The JavaScript methods of the `removeGl**` functions was rewritten to correctly remove an element identified by `layerId`
* `clearGlLayers` now correctly removes all Leaflet.Glify instances
* When showing/hiding Leaflet.Glify layers, they are set to active = TRUE/FALSE to make mouseevents work again. #48 #50

bug fixes

* src version now works also in shiny. #71
* Increase precision of points, lines and shapes by translating them closer to the Pixel Origin. Thanks @RayLarone #93
* src version now works also in shiny. #71
* added `popupOptions` and `labelOptions`. #83
* added `stroke` (default=TRUE) in `addGlPolygons` and `addGlPolygonsSrc` for drawing borders. #3 #68
* Labels work similar to `leaflet`. `leafgl` accepts a single string, a vector of strings or a formula. #78
* The `...` arguments are now passed to all methods in the underlying library. This allows us to set
additional arguments like `fragmentShaderSource`, `sensitivity` or `sensitivityHover`. #81

documentation etc

Expand Down
29 changes: 26 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,31 @@
# leafgl dev-version

- Added some @details for Shiny click and mouseover events and their corresponding input. [#77](https://github.com/r-spatial/leafgl/issues/77)
- Use `@inheritParams leaflet::**` for identical function arguments
- unified / simplified the dependency functions/calls

#### 🍬 miscellaneous

- update upstream javascript dependency to 3.3.0. [#49](https://github.com/r-spatial/leafgl/issues/49)
⚠️If you previously used the workaround `L.glify.Shapes.instances.splice(0, 1)`, please remove it with this new version.


# leafgl 0.2.2 (2024-11-13)

- Switched from `jsonify` and `geojsonsf` to `yyjsonr`
- New method `clearGlGroup` removes a group from leaflet and the Leaflet.Glify instances.
- The JavaScript methods of the `removeGl**` functions was rewritten to correctly remove an element identified by `layerId`
- `clearGlLayers` now correctly removes all Leaflet.Glify instances
- When showing/hiding Leaflet.Glify layers, they are set to active = TRUE/FALSE to make mouseevents work again. [#48](https://github.com/r-spatial/leafgl/issues/48) [#50](https://github.com/r-spatial/leafgl/issues/50)

#### 🐛 bug fixes

* src version now works also in shiny. #71
- Increase precision of points, lines and shapes by translating them closer to the Pixel Origin. Thanks @RayLarone [#93](https://github.com/r-spatial/leafgl/issues/93)
- src version now works also in shiny. [#71](https://github.com/r-spatial/leafgl/issues/71)
- added `popupOptions` and `labelOptions`. [#83](https://github.com/r-spatial/leafgl/issues/83)
- added `stroke` (default=TRUE) in `addGlPolygons` and `addGlPolygonsSrc` for drawing borders. [#3](https://github.com/r-spatial/leafgl/issues/3) [#68](https://github.com/r-spatial/leafgl/issues/68)
- Labels work similar to `leaflet`. `leafgl` accepts a single string, a vector of strings or a formula. [#78](https://github.com/r-spatial/leafgl/issues/78)
- The `...` arguments are now passed to all methods in the underlying library. This allows us to set additional arguments like `fragmentShaderSource`, `sensitivity` or `sensitivityHover`. [#81](https://github.com/r-spatial/leafgl/issues/81)

#### 💬 documentation etc

Expand All @@ -16,7 +39,7 @@

new features:

* all methods can now have labels/tooltips. Currently only lines and polygons support passing of a column name, points need a predefined label vector.
- all methods can now have labels/tooltips. Currently only lines and polygons support passing of a column name, points need a predefined label vector.

miscallaneous:

Expand All @@ -26,7 +49,7 @@ miscallaneous:

miscallaneous:

* update upstream javascript dependency to 3.2.0
- update upstream javascript dependency to 3.2.0

## leafgl 0.1.2

Expand Down
185 changes: 78 additions & 107 deletions R/glify-helpers.R
Original file line number Diff line number Diff line change
@@ -1,31 +1,16 @@
# helpers
glifyDependencies = function() {
# dependencies
glifyDependencies = function(src = FALSE) {
src <- ifelse(src, "Src", "")
list(
htmltools::htmlDependency(
"Leaflet.glify",
'3.2.0',
'3.3.1',
system.file("htmlwidgets/Leaflet.glify", package = "leafgl"),
script = c(
"addGlifyPoints.js"
, "addGlifyPolygons.js"
, "addGlifyPolylines.js"
, "glify-browser.js"
)
)
)
}

# helpers
glifyDependenciesSrc = function() {
list(
htmltools::htmlDependency(
"Leaflet.glifySrc",
'3.2.0',
system.file("htmlwidgets/Leaflet.glify", package = "leafgl"),
script = c(
"addGlifyPointsSrc.js"
, "addGlifyPolygonsSrc.js"
, "addGlifyPolylinesSrc.js"
"GlifyUtils.js"
, paste0("addGlifyPoints", src, ".js")
, paste0("addGlifyPolygons", src, ".js")
, paste0("addGlifyPolylines", src, ".js")
, "glify-browser.js"
)
)
Expand Down Expand Up @@ -56,101 +41,87 @@ glifyDataAttachmentSrc = function(fl_data, group, async = FALSE) {
}
}

glifyColorAttachmentSrc = function(fl_color, group) {
data_dir <- dirname(fl_color)
data_file <- basename(fl_color)
list(
htmltools::htmlDependency(
name = paste0(group, "col"),
version = 1,
src = c(file = data_dir),
script = list(data_file)
)
)
}

glifyPopupAttachmentSrc = function(fl_popup, group) {
data_dir <- dirname(fl_popup)
data_file <- basename(fl_popup)
glifyAttachmentSrc <- function(fl, group, type) {
valid_types <- c("col", "pop", "lab", "rad")
if (!type %in% valid_types) {
stop("Invalid type. Valid types are: col, pop, lab, rad.")
}
data_dir <- dirname(fl)
data_file <- basename(fl)
list(
htmltools::htmlDependency(
name = paste0(group, "pop"),
name = paste0(group, type),
version = 1,
src = c(file = data_dir),
script = list(data_file)
)
)
}

glifyRadiusAttachmentSrc = function(fl_radius, group) {
data_dir <- dirname(fl_radius)
data_file <- basename(fl_radius)
list(
htmltools::htmlDependency(
name = paste0(group, "rad"),
version = 1,
src = c(file = data_dir),
script = list(data_file)
)
)
}

glifyDataAttachment = function(fl_data, group) {
data_dir <- dirname(fl_data)
data_file <- basename(fl_data)
list(
htmltools::htmlDependency(
name = paste0(group, "dt"),
version = 1,
src = c(file = data_dir),
attachment = list(data_file)
)
)
# helpers
yyson_json_str <- function(x, ...) {
dt <- yyjsonr::write_json_str(x, ...)
class(dt) <- "json"
dt
}


glifyColorAttachment = function(fl_color, group) {
data_dir <- dirname(fl_color)
data_file <- basename(fl_color)
list(
htmltools::htmlDependency(
name = paste0(group, "cl"),
version = 1,
src = c(file = data_dir),
attachment = list(data_file)
)
)
}

glifyPopupAttachment = function(fl_popup, group) {
data_dir <- dirname(fl_popup)
data_file <- basename(fl_popup)
list(
htmltools::htmlDependency(
name = paste0(group, "pop"),
version = 1,
src = c(file = data_dir),
attachment = list(data_file)
)
)
yyson_geojson_str <- function(x, ...) {
dt <- yyjsonr::write_geojson_str(x, ...)
class(dt) <- "json"
dt
}




# helpers
glifyDependenciesFl = function() {
list(
htmltools::htmlDependency(
"Leaflet.glify",
'2.2.0',
system.file("htmlwidgets/Leaflet.glify", package = "leafgl"),
script = c(
"addGlifyPoints.js"
, "addGlifyPolygonsFl.js"
, "addGlifyPolylines.js"
, "glify.js"
)
)
)
}
## Not used ##########
# glifyDependenciesFl = function() {
# list(
# htmltools::htmlDependency(
# "Leaflet.glify",
# '2.2.0',
# system.file("htmlwidgets/Leaflet.glify", package = "leafgl"),
# script = c(
# "GlifyUtils.js"
# , "addGlifyPoints.js"
# , "addGlifyPolygonsFl.js"
# , "addGlifyPolylines.js"
# , "glify-browser.js"
# )
# )
# )
# }
# glifyDataAttachment = function(fl_data, group) {
# data_dir <- dirname(fl_data)
# data_file <- basename(fl_data)
# list(
# htmltools::htmlDependency(
# name = paste0(group, "dt"),
# version = 1,
# src = c(file = data_dir),
# attachment = list(data_file)
# )
# )
# }
# glifyColorAttachment = function(fl_color, group) {
# data_dir <- dirname(fl_color)
# data_file <- basename(fl_color)
# list(
# htmltools::htmlDependency(
# name = paste0(group, "cl"),
# version = 1,
# src = c(file = data_dir),
# attachment = list(data_file)
# )
# )
# }
# glifyPopupAttachment = function(fl_popup, group) {
# data_dir <- dirname(fl_popup)
# data_file <- basename(fl_popup)
# list(
# htmltools::htmlDependency(
# name = paste0(group, "pop"),
# version = 1,
# src = c(file = data_dir),
# attachment = list(data_file)
# )
# )
# }
Loading