Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Can I build a map using Leaflet for R and add it to a Power BI Report?

Hello and thanks for reading my question,

 

I like the specific map customization that Leaflet for R provides but need to present my work using Power BI.

Is there a way to render an html file in Power BI?

 

My R code is basic:

 

library(leaflet)
library(htmlwidgets)

 

path <- file.path(getwd(), "test.html")

m <- leaflet() %>% addTiles(urlTemplate = url,
attribution = '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>') %>%
addMarkers(lng = 174.768, lat = -36.852, popup = "Something")

m

saveWidget(m, file = path)

 

I also tried pasting that into the R script visualization with no success. I read about creating a custom visual with nodeJS, but not being an expert, that sounds a bit scary. What are my options?

 

Thanks again!

 

3 REPLIES 3
madalenapneves
New Member

Hi. I'm trying to do the same. I have a hexagon map in R that works just fine in leaflet, but when I add it to power BI as an R visual, it says it's not possible to present the visual element. 

I've tried creating my own visual, I've installed powershell and did all the pbiviz package tutorials I could find.

Is there a way to do this? If not, is there an alternative?

Anonymous
Not applicable

Hi @Anonymous,

AFAIK, power bi desktop has limitations to use R visual and r script so this code may not fully work well when you use on r visual.

You can take a look at the following document to know more about use R script in power bi:

Create Power BI visuals using R#known-limitations 

BTW, of these formulas work on power bi desktop side, you also need to pay attention about use them on power bi service side.
It not as same as executing R script on a local device, r script processing on a cloud server should have more limit and they may be blocked due to performance and security related reasons.

Create visuals by using R packages in the Power BI service 

Power BI Security#data-storage-security 

Regards,

Xiaoxin Sheng

amitchandak
Super User
Super User

@Anonymous , refer if one of these can help if you have not explored 

https://docs.microsoft.com/en-us/power-bi/visuals/service-r-visuals
https://blogs.perficient.com/2017/07/13/how-to-use-r-visuals-in-the-power-bi/
https://medium.com/@Konstantinos_Ioannou/how-to-create-an-r-custom-visual-html-for-powerbi-7f2d2e44e453

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.