leaflet-shiny and image overlay

781 views
Skip to first unread message

Olivier Nuñez

unread,
Jan 15, 2015, 10:17:17 AM1/15/15
to shiny-...@googlegroups.com

Dear all,

is there exist an easy way to add an image to a widget map created with leaflet() ?
That is, something equivalent to the imageOverlay layer from the Leaflet API documentation.
Thanks in advance. Olivier

Peter Ellis

unread,
Jan 16, 2015, 7:09:29 PM1/16/15
to shiny-...@googlegroups.com
Depending on what sort of image you mean, you could use the icon argument of addMarkers() in the way it is used to add an image of the R logo to a map in RStudio's intro to leaflet: http://rstudio.github.io/leaflet/#ui-layers

Olivier Nuñez

unread,
Jan 19, 2015, 5:56:44 AM1/19/15
to shiny-...@googlegroups.com
Thanks, but the size of a marker does not vary with the zoom.
I am rather interesting in a raster layer such like this: 

Olivier Nuñez

unread,
Jan 19, 2015, 8:59:57 AM1/19/15
to shiny-...@googlegroups.com
Finally, I figured out the following solution using rCharts:

require(rCharts)
map = Leaflet$new()
map$setView(c(40.71,-74.20),zoom=12)
map$setTemplate(afterScript = sprintf("<script>
imageBounds = [[40.712216, -74.22655], [40.773941, -74.12544]]
L.imageOverlay(imageUrl, imageBounds,{ opacity: .5}).addTo(map);
</script>"))
map
 
Reply all
Reply to author
Forward
0 new messages