Skip to content

Commit 83ca01c

Browse files
author
Tim Appelhans
committed
if logo width/height set to NULL, infer dims from image. addresses r-tmap/tmap#1038
1 parent 1e5fe10 commit 83ca01c

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

inst/htmlwidgets/lib/logo.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,22 @@ LeafletWidget.methods.addLogo = function(img, layerId, options) {
88
map.logos = [];
99
}
1010

11+
var imgElement = document.createElement('img');
12+
imgElement.src = img;
13+
imgElement.class = options.class;
14+
if (options.width !== undefined) {
15+
imgElement.width = options.width;
16+
}
17+
if (options.height !== undefined) {
18+
imgElement.height = options.height;
19+
}
20+
1121
// Create a new div for the logo
1222
var logoDiv = L.DomUtil.create('div', options.class);
1323
logoDiv.id = layerId;
1424
logoDiv.style.position = 'absolute';
15-
logoDiv.style.width = options.width + 'px';
16-
logoDiv.style.height = options.height + 'px';
25+
//logoDiv.style.width = options.width + 'px';
26+
//logoDiv.style.height = options.height + 'px';
1727
logoDiv.style.opacity = options.alpha;
1828
logoDiv.style.background = 'transparent';
1929

@@ -37,11 +47,6 @@ LeafletWidget.methods.addLogo = function(img, layerId, options) {
3747
}
3848

3949
// Create img-tag and append to document
40-
var imgElement = document.createElement('img');
41-
imgElement.src = img;
42-
imgElement.class = options.class;
43-
imgElement.width = options.width;
44-
imgElement.height = options.height;
4550
if (options.url) {
4651
var linkElement = document.createElement('a');
4752
linkElement.href = options.url;

0 commit comments

Comments
 (0)