Skip to content

Commit b5c8bb1

Browse files
authored
Merge pull request #95 from trafficonese/fixlabels
Fix labels/border/remove/clear-instances, **Src-functions, etc..
2 parents 8cb22f7 + 6a6a223 commit b5c8bb1

36 files changed

Lines changed: 1348 additions & 975 deletions

.github/workflows/R-CMD-check.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
R_KEEP_PKG_SOURCE: yes
3030

3131
steps:
32-
- uses: actions/checkout@v3
32+
- uses: actions/checkout@v4
3333

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

.github/workflows/test-coverage.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
1616

1717
steps:
18-
- uses: actions/checkout@v3
18+
- uses: actions/checkout@v4
1919

2020
- uses: r-lib/actions/setup-r@v2
2121
with:
@@ -44,7 +44,7 @@ jobs:
4444

4545
- name: Upload test results
4646
if: failure()
47-
uses: actions/upload-artifact@v3
47+
uses: actions/upload-artifact@v4
4848
with:
4949
name: coverage-test-failures
5050
path: ${{ runner.temp }}/package

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ Authors@R:
2929
Description: Provides bindings to the 'Leaflet.glify' JavaScript library which extends the 'leaflet' JavaScript library to render large data in the browser using 'WebGl'.
3030
License: MIT + file LICENSE
3131
Encoding: UTF-8
32+
LazyData: false
3233
RoxygenNote: 7.3.2
3334
Imports:
34-
geojsonsf,
3535
htmltools,
36-
jsonify,
3736
leaflet,
3837
sf,
38+
yyjsonr,
3939
grDevices
4040
Suggests:
4141
colourvalues,

NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ S3method(makePopup,shiny.tag)
2626
export(addGlPoints)
2727
export(addGlPolygons)
2828
export(addGlPolylines)
29+
export(clearGlGroup)
2930
export(clearGlLayers)
3031
export(leafglOutput)
3132
export(makeColorMatrix)
@@ -37,5 +38,6 @@ export(renderLeafgl)
3738
importFrom(htmltools,htmlDependencies)
3839
importFrom(htmltools,tagList)
3940
importFrom(htmltools,tags)
41+
importFrom(leaflet,evalFormula)
4042
importFrom(leaflet,leafletOutput)
4143
importFrom(leaflet,renderLeaflet)

NEWS

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,32 @@
1+
leafgl development-version
2+
3+
* Added some @details for Shiny click and mouseover events and their corresponding input. #77
4+
* Use `@inheritParams leaflet::**` for identical function arguments
5+
6+
miscellaneous
7+
8+
* update upstream javascript dependency to 3.3.1. #49
9+
Note: If you previously used the workaround `L.glify.Shapes.instances.splice(0, 1)`, please remove it with this new version.
10+
* unified / simplified the dependency functions/calls
11+
12+
113
leafgl 0.2.2 (2024-11-13)
214

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

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

731
documentation etc
832

NEWS.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,31 @@
1+
# leafgl dev-version
2+
3+
- Added some @details for Shiny click and mouseover events and their corresponding input. [#77](https://github.com/r-spatial/leafgl/issues/77)
4+
- Use `@inheritParams leaflet::**` for identical function arguments
5+
- unified / simplified the dependency functions/calls
6+
7+
#### 🍬 miscellaneous
8+
9+
- update upstream javascript dependency to 3.3.0. [#49](https://github.com/r-spatial/leafgl/issues/49)
10+
⚠️If you previously used the workaround `L.glify.Shapes.instances.splice(0, 1)`, please remove it with this new version.
11+
12+
113
# leafgl 0.2.2 (2024-11-13)
214

15+
- Switched from `jsonify` and `geojsonsf` to `yyjsonr`
16+
- New method `clearGlGroup` removes a group from leaflet and the Leaflet.Glify instances.
17+
- The JavaScript methods of the `removeGl**` functions was rewritten to correctly remove an element identified by `layerId`
18+
- `clearGlLayers` now correctly removes all Leaflet.Glify instances
19+
- 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)
20+
321
#### 🐛 bug fixes
422

5-
* src version now works also in shiny. #71
23+
- 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)
24+
- src version now works also in shiny. [#71](https://github.com/r-spatial/leafgl/issues/71)
25+
- added `popupOptions` and `labelOptions`. [#83](https://github.com/r-spatial/leafgl/issues/83)
26+
- 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)
27+
- 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)
28+
- 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)
629

730
#### 💬 documentation etc
831

@@ -16,7 +39,7 @@
1639

1740
new features:
1841

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

2144
miscallaneous:
2245

@@ -26,7 +49,7 @@ miscallaneous:
2649

2750
miscallaneous:
2851

29-
* update upstream javascript dependency to 3.2.0
52+
- update upstream javascript dependency to 3.2.0
3053

3154
## leafgl 0.1.2
3255

R/glify-helpers.R

Lines changed: 78 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,16 @@
1-
# helpers
2-
glifyDependencies = function() {
1+
# dependencies
2+
glifyDependencies = function(src = FALSE) {
3+
src <- ifelse(src, "Src", "")
34
list(
45
htmltools::htmlDependency(
56
"Leaflet.glify",
6-
'3.2.0',
7+
'3.3.1',
78
system.file("htmlwidgets/Leaflet.glify", package = "leafgl"),
89
script = c(
9-
"addGlifyPoints.js"
10-
, "addGlifyPolygons.js"
11-
, "addGlifyPolylines.js"
12-
, "glify-browser.js"
13-
)
14-
)
15-
)
16-
}
17-
18-
# helpers
19-
glifyDependenciesSrc = function() {
20-
list(
21-
htmltools::htmlDependency(
22-
"Leaflet.glifySrc",
23-
'3.2.0',
24-
system.file("htmlwidgets/Leaflet.glify", package = "leafgl"),
25-
script = c(
26-
"addGlifyPointsSrc.js"
27-
, "addGlifyPolygonsSrc.js"
28-
, "addGlifyPolylinesSrc.js"
10+
"GlifyUtils.js"
11+
, paste0("addGlifyPoints", src, ".js")
12+
, paste0("addGlifyPolygons", src, ".js")
13+
, paste0("addGlifyPolylines", src, ".js")
2914
, "glify-browser.js"
3015
)
3116
)
@@ -56,101 +41,87 @@ glifyDataAttachmentSrc = function(fl_data, group, async = FALSE) {
5641
}
5742
}
5843

59-
glifyColorAttachmentSrc = function(fl_color, group) {
60-
data_dir <- dirname(fl_color)
61-
data_file <- basename(fl_color)
62-
list(
63-
htmltools::htmlDependency(
64-
name = paste0(group, "col"),
65-
version = 1,
66-
src = c(file = data_dir),
67-
script = list(data_file)
68-
)
69-
)
70-
}
71-
72-
glifyPopupAttachmentSrc = function(fl_popup, group) {
73-
data_dir <- dirname(fl_popup)
74-
data_file <- basename(fl_popup)
44+
glifyAttachmentSrc <- function(fl, group, type) {
45+
valid_types <- c("col", "pop", "lab", "rad")
46+
if (!type %in% valid_types) {
47+
stop("Invalid type. Valid types are: col, pop, lab, rad.")
48+
}
49+
data_dir <- dirname(fl)
50+
data_file <- basename(fl)
7551
list(
7652
htmltools::htmlDependency(
77-
name = paste0(group, "pop"),
53+
name = paste0(group, type),
7854
version = 1,
7955
src = c(file = data_dir),
8056
script = list(data_file)
8157
)
8258
)
8359
}
8460

85-
glifyRadiusAttachmentSrc = function(fl_radius, group) {
86-
data_dir <- dirname(fl_radius)
87-
data_file <- basename(fl_radius)
88-
list(
89-
htmltools::htmlDependency(
90-
name = paste0(group, "rad"),
91-
version = 1,
92-
src = c(file = data_dir),
93-
script = list(data_file)
94-
)
95-
)
96-
}
9761

98-
glifyDataAttachment = function(fl_data, group) {
99-
data_dir <- dirname(fl_data)
100-
data_file <- basename(fl_data)
101-
list(
102-
htmltools::htmlDependency(
103-
name = paste0(group, "dt"),
104-
version = 1,
105-
src = c(file = data_dir),
106-
attachment = list(data_file)
107-
)
108-
)
62+
# helpers
63+
yyson_json_str <- function(x, ...) {
64+
dt <- yyjsonr::write_json_str(x, ...)
65+
class(dt) <- "json"
66+
dt
10967
}
110-
111-
112-
glifyColorAttachment = function(fl_color, group) {
113-
data_dir <- dirname(fl_color)
114-
data_file <- basename(fl_color)
115-
list(
116-
htmltools::htmlDependency(
117-
name = paste0(group, "cl"),
118-
version = 1,
119-
src = c(file = data_dir),
120-
attachment = list(data_file)
121-
)
122-
)
123-
}
124-
125-
glifyPopupAttachment = function(fl_popup, group) {
126-
data_dir <- dirname(fl_popup)
127-
data_file <- basename(fl_popup)
128-
list(
129-
htmltools::htmlDependency(
130-
name = paste0(group, "pop"),
131-
version = 1,
132-
src = c(file = data_dir),
133-
attachment = list(data_file)
134-
)
135-
)
68+
yyson_geojson_str <- function(x, ...) {
69+
dt <- yyjsonr::write_geojson_str(x, ...)
70+
class(dt) <- "json"
71+
dt
13672
}
13773

13874

139-
140-
141-
# helpers
142-
glifyDependenciesFl = function() {
143-
list(
144-
htmltools::htmlDependency(
145-
"Leaflet.glify",
146-
'2.2.0',
147-
system.file("htmlwidgets/Leaflet.glify", package = "leafgl"),
148-
script = c(
149-
"addGlifyPoints.js"
150-
, "addGlifyPolygonsFl.js"
151-
, "addGlifyPolylines.js"
152-
, "glify.js"
153-
)
154-
)
155-
)
156-
}
75+
## Not used ##########
76+
# glifyDependenciesFl = function() {
77+
# list(
78+
# htmltools::htmlDependency(
79+
# "Leaflet.glify",
80+
# '2.2.0',
81+
# system.file("htmlwidgets/Leaflet.glify", package = "leafgl"),
82+
# script = c(
83+
# "GlifyUtils.js"
84+
# , "addGlifyPoints.js"
85+
# , "addGlifyPolygonsFl.js"
86+
# , "addGlifyPolylines.js"
87+
# , "glify-browser.js"
88+
# )
89+
# )
90+
# )
91+
# }
92+
# glifyDataAttachment = function(fl_data, group) {
93+
# data_dir <- dirname(fl_data)
94+
# data_file <- basename(fl_data)
95+
# list(
96+
# htmltools::htmlDependency(
97+
# name = paste0(group, "dt"),
98+
# version = 1,
99+
# src = c(file = data_dir),
100+
# attachment = list(data_file)
101+
# )
102+
# )
103+
# }
104+
# glifyColorAttachment = function(fl_color, group) {
105+
# data_dir <- dirname(fl_color)
106+
# data_file <- basename(fl_color)
107+
# list(
108+
# htmltools::htmlDependency(
109+
# name = paste0(group, "cl"),
110+
# version = 1,
111+
# src = c(file = data_dir),
112+
# attachment = list(data_file)
113+
# )
114+
# )
115+
# }
116+
# glifyPopupAttachment = function(fl_popup, group) {
117+
# data_dir <- dirname(fl_popup)
118+
# data_file <- basename(fl_popup)
119+
# list(
120+
# htmltools::htmlDependency(
121+
# name = paste0(group, "pop"),
122+
# version = 1,
123+
# src = c(file = data_dir),
124+
# attachment = list(data_file)
125+
# )
126+
# )
127+
# }

0 commit comments

Comments
 (0)