Skip to content

Commit a4875a3

Browse files
start to remove leaflet-label since now L.tooltip
1 parent 55334c1 commit a4875a3

File tree

10 files changed

+55
-774
lines changed

10 files changed

+55
-774
lines changed

R/layers.R

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -497,12 +497,14 @@ safeLabel <- function(label, data) {
497497

498498
#' @param
499499
#' noHide,direction,offset,textsize,textOnly,style
500-
#' label options; see \url{https://github.com/Leaflet/Leaflet.label#options}
500+
#' label options; see \url{http://leafletjs.com/reference-1.0.3.html#tooltip-option}
501501
#' @describeIn map-options Options for labels
502502
#' @export
503503
labelOptions <- function(
504-
clickable = FALSE,
505-
noHide = FALSE,
504+
interactive = FALSE,
505+
clickable = NULL,
506+
noHide = NULL,
507+
permanent = FALSE,
506508
className = '',
507509
direction = 'right',
508510
#pane = NULL,
@@ -514,8 +516,13 @@ labelOptions <- function(
514516
zoomAnimation = TRUE,
515517
...
516518
) {
519+
# use old clickable if provided
520+
if(!is.null(clickable) && interactive != clickable) interactive <- clickable
521+
# use old noHide if provided
522+
if(!is.null(noHide) && permanent != noHide) permanent <- noHide
523+
517524
list(
518-
clickable = clickable, noHide = noHide, direction = direction,
525+
interactive = interactive, permanent = permanent, direction = direction,
519526
opacity = opacity, offset = offset,
520527
textsize = textsize, textOnly = textOnly, style = style,
521528
zoomAnimation = zoomAnimation, className = className, ...

inst/errors/errors.Rmd

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,32 @@ fixed but not solved [commit](https://github.com/timelyportfolio/leaflet/commit/
1616

1717
### controls
1818

19-
leaflet-measure, layersControl, and probably others do not remove
19+
leaflet-measure and layersControl do not remove
2020

21+
not an `v1.0.3` issue but fixed [commit](https://github.com/timelyportfolio/leaflet/commit/c6762e313f268954d8c19225177a991129c20a98) and [commit](https://github.com/timelyportfolio/leaflet/commit/55334c10536f6bc0b7250139e64e262f2cb48c51). However, none of controls use `ControlStore` mechanism, so would be nice to resolve this on a grander scale.
22+
23+
24+
### labels/tooltips
25+
26+
https://github.com/Leaflet/Leaflet.label#upgrade-path-to-ltooltip
27+
28+
leaflet-label now in main leaflet as L.tooltip. How do we handle changed options in `labelOptions`?. Do we just translate `clickable` to `interactive` and `clickable` to `interactive` in R so old examples still work?
29+
30+
**NOTE: starting with Leaflet 1.0, `L.Label` is added to Leaflet core as `L.Tooltip` and this plugin is deprecrated.**
31+
32+
### Upgrade path to L.Tooltip
33+
34+
- `bindLabel`, `openLabel` and so should be replaced by `bindTooltip`, `openTooltip`, etc.
35+
- option `clickable` is now named `interactive`
36+
- option `noHide` is now named `permanent`
37+
- default `offset` is now [6, -6]
38+
- default `direction` is now `auto`
39+
- default `opacity` is now `0.9`
40+
- the CSS has been fully refactored
41+
42+
- Bonus: L.Tooltip also works for paths: polygons, polylines, etc.
43+
- Bonus: new directions are supported: `top`, `bottom`, `center`
44+
- Bonus: new option `sticky` will make the label follow the mouse instead of being displayed at the feature center
45+
46+
47+
# removed leaflet-label source and in yaml in [commit]()

inst/htmlwidgets/leaflet.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,12 +1317,12 @@ function addMarkers(map, df, group, clusterOptions, clusterId, markerFunc) {
13171317
if (label !== null) {
13181318
if (labelOptions !== null) {
13191319
if (labelOptions.noHide) {
1320-
marker.bindLabel(label, labelOptions).showLabel();
1320+
marker.bindTooltip(label, labelOptions).showLabel();
13211321
} else {
1322-
marker.bindLabel(label, labelOptions);
1322+
marker.bindTooltip(label, labelOptions);
13231323
}
13241324
} else {
1325-
marker.bindLabel(label);
1325+
marker.bindTooltip(label);
13261326
}
13271327
}
13281328
marker.on("click", mouseHandler(this.id, thisId, thisGroup, "marker_click", extraInfo), this);
@@ -1462,14 +1462,14 @@ function addLayers(map, category, df, layerFunc) {
14621462
}
14631463
}
14641464
}
1465-
if (layer.bindLabel) {
1465+
if (layer.bindTooltip) {
14661466
var label = df.get(i, "label");
14671467
var labelOptions = df.get(i, "labelOptions");
14681468
if (label !== null) {
14691469
if (labelOptions !== null) {
1470-
layer.bindLabel(label, labelOptions);
1470+
layer.bindTooltip(label, labelOptions);
14711471
} else {
1472-
layer.bindLabel(label);
1472+
layer.bindTooltip(label);
14731473
}
14741474
}
14751475
}

inst/htmlwidgets/leaflet.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ dependencies:
1212
version: 1.0.0
1313
src: "htmlwidgets/lib/leafletfix"
1414
stylesheet: leafletfix.css
15-
- name: leaflet-label
16-
version: 0.2.2
17-
src: "htmlwidgets/lib/Leaflet.label"
18-
script: leaflet.label.js
19-
stylesheet: leaflet.label.css
2015
- name: Proj4Leaflet
2116
version: 0.7.2
2217
src: "htmlwidgets/plugins/Proj4Leaflet"
-3.31 KB
Binary file not shown.

0 commit comments

Comments
 (0)