I have a rmap in a Shiny app. I want to be able to add markers as I select locations from a checkbox group. I have tried a few ways, including a for loop over map1$marker(...). The problem is that once I change the input the map goes blank and doesn't update.
Here is my code (this code is a later attempt where I tried to use if statements, which are obviously restrictive... same problem, anyways)
## MAP
output$map_lib <- renderMap({
# make map
map1 = Leaflet$new()
map1$setView(c(41.8878251,-87.6494323), 10)
map1$tileLayer("https://cdn1.apple-mapkit.com/tp/tile?type=tile&style=0&size=1&x={x}&y={y}&z={z}&scale=1&lang=en-US&imageFormat=jpg&vendorkey=546bccd01bb595c1ae74836bf94b56735aa7f907&cacheVersion=5&v=1406167")
map1$set(dom = 'map_lib')
map1$set(height = 550, width = 500)
# markers
coord <- subset(coordinates.global, coordinates.global$branch %in% lib_sum_select())
if(length(coord$branch)<=1){
lat <- coord[1,2]
long <- coord[1,3]
name <- as.character(coord[1,1])
map1$marker(c(lat, long), bindPopup = name)
}
if(length(coord$branch)<=2){
lat <- coord[2,2]
long <- coord[2,3]
name <- as.character(coord[2,1])
map1$marker(c(lat, long), bindPopup = name)
}
if(length(coord$branch)<=3){
lat <- coord[3,2]
long <- coord[3,3]
name <- as.character(coord[3,1])
map1$marker(c(lat, long), bindPopup = name)
}
# finally try the map
map1
})
I have a rmap in a Shiny app. I want to be able to add markers as I select locations from a checkbox group. I have tried a few ways, including a for loop over map1$marker(...). The problem is that once I change the input the map goes blank and doesn't update.
Here is my code (this code is a later attempt where I tried to use if statements, which are obviously restrictive... same problem, anyways)