Numbers for markers in leaflet package?

Hi everybody.
Not sure that it is the right place for my question, but did not find anything better.
In my Shiny app I use markers for mapping geolocation.
I am trying to add numbers to these markers.

So far, I found something for js, but I am totally unfamiliar with it.

http://charliecroom.com/index.php/web/numbered-markers-in-leaflet

Can it be solved only using R packages?

Sincerely
Oleksiy

1 Like

Resolved personally.

library(leaflet)
library(dplyr) 

Each icon was customized with numbers personally and was put into the working directory.

Then use icon_list()

# Create our own custom icons
icon_list <- iconList(
project1 = makeIcon("C:/Map/1.png", iconWidth = 24, iconHeight = 30),
project2 = makeIcon("C:/Map/2.png", iconWidth = 24, iconHeight = 30)

etc as many as you have

project1, project2 etc match the same names in the dataset column of course and in the dataset each project should have long and lat.

Then

data2 <- data %>% mutate(type = factor(data$project_id), c("project1", 
"project2") 

In server, the simple code will be something like this

m <-  leaflet(data=data) %>% 
addProviderTiles(providers$Stamen.TonerLite) %>%
addMarkers(~data2$long, ~data2$lat, icon=~icon_list[data2$project_id], 
popup = state_popup)

Thanks to this question on stack overflow

3 Likes