cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

leaflet not works in notebook(R language)

yalei
New Contributor

I saw this notebook: htmlwidgets-azure - Databricks (microsoft.com)

However, it is not reproducible. I got a lot errors:

  1. there is no package called โ€˜R.utilsโ€™. This is easy to fix, just install the package "R.utils"
  2. "can not be unloaded". This is not a way one, I tried to remove htmltools and install again. somehow, it is fixed
Error in value[[3L]](cond) : 
  Package โ€˜htmltoolsโ€™ version 0.5.3 cannot be unloaded:
 Error in unloadNamespace(package) : namespace โ€˜htmltoolsโ€™ is imported by โ€˜htmlwidgetsโ€™, โ€˜shinyโ€™ so cannot be unloaded
 
Error in value[[3L]](cond): Package โ€˜htmltoolsโ€™ version 0.5.3 cannot be unloaded:
  1. After fixing all the package errors, the plotly package finally works. However, leaflet and dygraphs print nothing in the notebook. I downloaded the generated html files in /dbfs/FileStore/rwidgets and tested them locally, the map works. It just does not show up in the notebook.

Here is my testing environment:

runtime: 11.3 LTS (includes Apache Spark 3.3.0, Scala 2.12)

note: standard_F4

1 REPLY 1

Kaniz
Community Manager
Community Manager

Hi @yalei duโ€‹, Thank you for contacting us regarding the issues you're experiencing with the Leaflet and Dygraphs packages in your R notebook. I understand you have successfully installed the required packages, but the visualizations are not in the notebook.

Based on your description, the issue may relate to how your notebook is set up or the output rendered. Here are some steps you can try to resolve the issue:

  • Update the packages: Make sure you have the latest versions of the packages installed. Run the following commands to update them:
install.packages("leaflet")
install.packages("dygraphs")
  • Render the output as HTML: To ensure your notebook can render the output as HTML, you can try using the IRdisplay package. Install it if you haven't already:
install.packages("IRdisplay")
  • Then, use the following code snippet to render the Leaflet map as an HTML widget:
library(IRdisplay)
library(leaflet)
 
map <- leaflet() %>% addTiles()
display_html(as.character(map))
  • Check browser compatibility: Ensure you use a compatible and updated web browser. Using the latest version of Google Chrome or Mozilla Firefox is recommended for the best experience.
  • Clear browser cache: Sometimes, cached files can cause display issues. Clear your browser's cache and refresh the page to see if the problem is resolved.
  • Inspect browser console for errors: Open the browser console (usually by pressing F12) and check for any errors related to rendering the Leaflet or Dygraphs output.

If none of these suggestions resolve the issue, please provide us with any error messages, relevant code snippets, or screenshots of your notebook, and we'll be happy to investigate further.

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.