0

I am trying to add multiple row table in leaflet map R for each polygon, which should popup while clicking the polygon. PopupTable() only allows single row to popup. Please suggest me a better option to do this.

I couldn't find a better way to implement this.

Thanks in advance

1 Answer 1

0

Hard to answer without sample data.. but here is an approach:

put the popups in a list, and add this list as popup with HTML code

library(htmltools)
library(leaflet)
library(magrittr) # for the %>% operator

mylabels <- lapply( seq(nrow(mydf)), function(i) {
  paste0( '<p><b>', mydf[i, "column_1"], '</b><br>', 
          mydf[i, "column_2"], 'my_text'</p>)
})

leaflet() %>% 
  addTiles() %>% 
  addCircleMarkers(data = mydf,
                   lat = ~latitude, 
                   lng = ~longitude,
                   #here go the labels
                   popup = lapply(mylabels, HTML))

Not the answer you're looking for? Browse other questions tagged or ask your own question.