I am trying to see if you can create a tmap map, convert it to a leaflet map, and then add leaflet features.
For example:
battle_dat<-read.csv("GeoBattleData_YZ.csv") # from https://doi.org/10.7910/DVN/1KCCX2
battle_dat<-battle_dat %>% select(war,atkr,defr,date,long,lat,dist_att,dist_def,duration) %>%
mutate(year=substr(date,1,4))
battle_dat<-battle_dat[!is.na(battle_dat$long),]
battle_dat<-SpatialPointsDataFrame(coords = battle_dat[,c(5:6)],data = battle_dat,proj4string=CRS("+init=EPSG:4326"))
tm<-tm_shape(dat) + tm_dots(col="duration") # make tmap
tm<-tmap_leaflet(tm) # convert to leaflet
tm %>%
addDrawToolbar(
targetGroup='draw',
polylineOptions=FALSE,
markerOptions = FALSE,
circleOptions = T,
polygonOptions=F,
singleFeature=T,
circleMarkerOptions=F)
I get the following error:
"Error in dispatch(map, method, leaflet = { : Invalid map parameter"
So, I am not sure if this an issue on my end or if I simply cannot do what I'm trying to do. It's not that big of a deal, but I find that it is easier to do some things in tmap and other things in leaflet.