|
1 | | -# helpers |
2 | | -glifyDependencies = function() { |
| 1 | +# dependencies |
| 2 | +glifyDependencies = function(src = FALSE) { |
| 3 | + src <- ifelse(src, "Src", "") |
3 | 4 | list( |
4 | 5 | htmltools::htmlDependency( |
5 | 6 | "Leaflet.glify", |
6 | | - '3.2.0', |
| 7 | + '3.3.1', |
7 | 8 | system.file("htmlwidgets/Leaflet.glify", package = "leafgl"), |
8 | 9 | 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") |
29 | 14 | , "glify-browser.js" |
30 | 15 | ) |
31 | 16 | ) |
@@ -56,101 +41,87 @@ glifyDataAttachmentSrc = function(fl_data, group, async = FALSE) { |
56 | 41 | } |
57 | 42 | } |
58 | 43 |
|
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) |
75 | 51 | list( |
76 | 52 | htmltools::htmlDependency( |
77 | | - name = paste0(group, "pop"), |
| 53 | + name = paste0(group, type), |
78 | 54 | version = 1, |
79 | 55 | src = c(file = data_dir), |
80 | 56 | script = list(data_file) |
81 | 57 | ) |
82 | 58 | ) |
83 | 59 | } |
84 | 60 |
|
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 | | -} |
97 | 61 |
|
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 |
109 | 67 | } |
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 |
136 | 72 | } |
137 | 73 |
|
138 | 74 |
|
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