2

I am having issues with displaying leaflet tiles using the leaflet R package in power bi custom visuals.

Following this procedure explaining how to use custom visuals in Power BI, I used the following code :

source('./r_files/flatten_HTML.r')

library(dplyr)
library(leaflet)

dataset <- Values
m <- leaflet() %>%   addProviderTiles("Stamen.Watercolor") %>% 
addCircleMarkers(dataset$lng, dataset$lat, radius = dataset$size) %>% 
addCircleMarkers(dataset$lng, dataset$lat, radius = runif(100, 4, 10), color = c("red"))

internalSaveWidget(m, 'out.html');

My dataset looks like this (I have the same issue with any dataset, including those used in the leaflet help) :

dput(head(dataset))

structure(list(value = c(0.0312819085485015, -0.0347865234437622, 
-0.0483830686065398, -0.0549732174222513, -0.066608077878619, 
-0.074376647461119), size = c(19.5772261708044, 9.14226635242812, 
6.23493849067017, 17.0839378878009, 13.8565228821244, 10.3433380043134
), lng = c(-93.6313250520961, -93.6473800245603, -93.6538138931705, 
-93.6456154972455, -93.6484166098675, -93.6543456657981), lat =         c(42.0347684275463, 
42.0326412382433, 42.0269432323368, 42.0222304571459, 42.0314391809256, 
42.0405492323631), Column1 = c(61L, 64L, 92L, 68L, 74L, 21L), 
category = structure(c(9L, 6L, 4L, 2L, 10L, 4L), .Label = c("A", 
"B", "C", "D", "E", "F", "G", "H", "I", "J"), class = "factor")), row.names = c(NA, 
6L), class = "data.frame")

As shown in the following image the circle are displaying correctly but the background remains empty.

yoyo
  • 121
  • 3
  • Welcome to Stack Overflow! Please try reading up on how to ask a question, that can be answered by others: https://stackoverflow.com/help/how-to-ask. There are several ways to provide data, probably adding the output of `dput()` or `dput(head())` to your question is sufficient. Avoid adding code or alphanumeric output as images. Consider checking out how to make a good reproducible example https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example and see how you can change your question accordingly. – heck1 Mar 13 '19 at 13:07
  • Thanks for your message, I have edited my question accordingly – yoyo Mar 14 '19 at 08:02

1 Answers1

0

I finally found an alternative, using tiles provided there.

The following syntax must be used (example with the OpenTopoMap tiles) :

leaflet() %>%   
addTiles("https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png") %>%
addCircleMarkers(dataset$lng, dataset$lat, radius = dataset$size) %>% 
addCircleMarkers(dataset$lng, dataset$lat, radius = runif(100, 4, 10), color = c("red"))
yoyo
  • 121
  • 3