Skip to content

Commit 96667e3

Browse files
step toward fixing broken addRasterImage; displays now but still not working
1 parent aba117c commit 96667e3

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

inst/errors/errors.Rmd

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,13 @@ leaflet-label now in main leaflet as L.tooltip. How do we handle changed option
4444
- Bonus: new option `sticky` will make the label follow the mouse instead of being displayed at the feature center
4545

4646

47-
# removed leaflet-label source and in yaml in [commit]()
47+
* removed leaflet-label source and in yaml in [commit]()
48+
49+
50+
### tileLayer.canvas no longer available
51+
52+
```
53+
library(mapview)
54+
55+
leaflet() %>% addRasterImage(poppendorf[[1]])
56+
```

inst/htmlwidgets/leaflet.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2100,14 +2100,17 @@ methods.addRasterImage = function (uri, bounds, opacity, attribution, layerId, g
21002100
};
21012101
img.src = uri;
21022102

2103-
var canvasTiles = _leaflet2.default.tileLayer.canvas({
2103+
var canvasTiles = _leaflet2.default.gridLayer({
21042104
opacity: opacity,
21052105
attribution: attribution,
21062106
detectRetina: true,
21072107
async: true
21082108
});
21092109

2110-
canvasTiles.drawTile = function (canvas, tilePoint, zoom) {
2110+
canvasTiles.createTile = function (tilePoint) {
2111+
var zoom = tilePoint.z;
2112+
var canvas = _leaflet2.default.DomUtil.create("canvas", "leaflet-tile");
2113+
21112114
getImageData(function (imgData, w, h, mipmapper) {
21122115
try {
21132116
var _ret7 = function () {
@@ -2236,9 +2239,10 @@ methods.addRasterImage = function (uri, bounds, opacity, attribution, layerId, g
22362239

22372240
if ((typeof _ret7 === "undefined" ? "undefined" : _typeof(_ret7)) === "object") return _ret7.v;
22382241
} finally {
2239-
canvasTiles.tileDrawn(canvas);
2242+
return canvas;
22402243
}
22412244
});
2245+
return canvas;
22422246
};
22432247

22442248
this.layerManager.addLayer(canvasTiles, "image", layerId, group);

javascript/src/methods.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,14 +1034,17 @@ methods.addRasterImage = function(uri, bounds, opacity, attribution, layerId, gr
10341034
};
10351035
img.src = uri;
10361036

1037-
let canvasTiles = L.tileLayer.canvas({
1037+
let canvasTiles = L.gridLayer({
10381038
opacity: opacity,
10391039
attribution: attribution,
10401040
detectRetina: true,
10411041
async: true
10421042
});
10431043

1044-
canvasTiles.drawTile = function(canvas, tilePoint, zoom) {
1044+
canvasTiles.createTile = function(tilePoint) {
1045+
let zoom = tilePoint.z;
1046+
let canvas = L.DomUtil.create("canvas", "leaflet-tile");
1047+
10451048
getImageData(function(imgData, w, h, mipmapper) {
10461049
try {
10471050
// The Context2D we'll being drawing onto. It's always 256x256.
@@ -1171,9 +1174,10 @@ methods.addRasterImage = function(uri, bounds, opacity, attribution, layerId, gr
11711174
}
11721175
}
11731176
} finally {
1174-
canvasTiles.tileDrawn(canvas);
1177+
return canvas;
11751178
}
11761179
});
1180+
return canvas;
11771181
};
11781182

11791183
this.layerManager.addLayer(canvasTiles, "image", layerId, group);

0 commit comments

Comments
 (0)