0

I'm trying to make a webpage with Rapache and "Leaflet for R". The main reason I did install Rapache is to use R inside of a html page (with brew). But, I cant figure out how to return my map inside the html page without saving it as a html extern file (which Rapache is useless). Lets take a exemple :

<%
library(leaflet)

m <- leaflet()
m <- addTiles(m)
m <- addMarkers(m, lng=174.768, lat=-36.852, popup="The birthplace of R")
m #Does not show anything
saveWidget(m, file = outPath, selfcontained = FALSE, libdir ='leafletwidget_libs') #work but not proper
%>

This is what I have in my html file and I would like to be able to return this map (m) and add it somewhere on my current page. The main reason I would like to do this is because I'm going to use this on a website and i would like it to be dynamic and not creating plenty of htmlfile. This is not really proper. Hope you can help me :) Thanks you !

KingOfBabu
  • 409
  • 3
  • 21
  • what do you mean by #work but not proper – MLavoie Dec 15 '15 at 21:54
  • On the website I will have alot of different data to add on the map (raster-map) and this data can be added at anytime. So I think its better to not save plenty of html files – KingOfBabu Dec 15 '15 at 22:04
  • have you tried m <- leaflet() %>% addTiles() %>% addMarkers(data=m, lng=174.768, lat=-36.852, popup="The birthplace of R"); m; m should open in your browser – MLavoie Dec 15 '15 at 22:06
  • Yes, this is what i tried and and it work when I tape the code on R but on Rapache, it doesn't show anything (blank page) – KingOfBabu Dec 15 '15 at 22:15

1 Answers1

0

In order to use this type of file on our web dashboards we create a space using iFrames which defines the area the swidget will load into, it has worked very well for us. Have you tried using iFrames?

exapmple code to embed it with suggestions about folder management

You can tweak the size of the frame using traditional front-end practices.

Community
  • 1
  • 1
sconfluentus
  • 4,693
  • 1
  • 21
  • 40