I'm playing with leaflet in shiny app, and I would like to get information about the marker I'm clicking on. At this point I have a nice map with marker, but how can I return information about the marker I click on?
my server.R
library(shiny)
library(leaflet)
library(rgdal)
setwd("~/github/shiny_stuff/banyuls_map/")
####load data converted in geojson
capteurs<-readOGR("./data/capteurs.geojson", "OGRGeoJSON")
shinyServer(function(input, output, session) {
map <- createLeafletMap(session, "map")
session$onFlushed(once=TRUE, function() {
map$addMarker(capteurs@coords[,2],
capteurs@coords[,1]
)
})
})
my ui.R
library(shiny)
library(leaflet)
shinyUI(fluidPage(
titlePanel("title panel"),
leafletMap(
"map", "100%", 400,
initialTileLayer = "//{s}.tiles.mapbox.com/v3/jcheng.map-5ebohr46/{z}/{x}/{y}.png",
initialTileLayerAttribution = HTML('Maps by <a href="http://www.mapbox.com/">Mapbox</a>'),
options=list(
center = c(42.4797, 3.1181),
zoom = 12
)
),
))