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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
ctruxillo
Regular Visitor

Mapping with R code Leaflet or other packages

Hi I am trying to build a map that I can connect cordinates and fill in the area. I have had success with Rstudio but would prefer to get the code to work in PowerBi.  the Rstudio code I used is 

 

library(dplyr)
library(leaflet)

map<-leaflet(width =500, height= 500) %>%
addTiles() %>%
addPolygons(lng =                c(-76.12483,-75.49118,-75.01104,-75.05677,-75.37360,-76.27835,-77.11451,-76.60171,-76.77809,-76.50045,-76.12483), lat=c(38.56060,39.18615,38.64739,37.87028,37.49547,37.17344,37.33463,38.01968,38.34830,38.59635,38.56060)) %>%
addCircles(lng = c(-76), lat= c(38), color ="red",weight = 70 )

 

map

 

 

 

I am hand writting the cordinates to test but plan on using a datafile instead. The issue I am getting is that Power Bi is reporting  that no visual was created, but this produces one in Rstudio. From my understanding, leaflet is supported in PowerBi (according to Learn which R packages are supported - Power BI | Microsoft Learn). 

ctruxillo_0-1668699058990.png

 

 

Is there something else I would need to add to the code to get it to show up? Are there better packages for the job? Heck, if there is a good power bi specific solution I would love that. Thanks for your input!

1 REPLY 1
Anonymous
Not applicable

Hi @ctruxillo ,

 

Please make sure you have installed the node.js.

Here is a solved post with similar issue like yours, I hope it could help you.

You may refer to offical blogs to learn more details.

For reference:

Run R scripts in Power BI Desktop

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.