How can I change the unit of the circle's radius that can be drawn with the following script? It displays it in feet and I need it in kilometers. Changing it for the whole DrawToolbar would be even better.
library(shiny)
library(leaflet)
library(leaflet.extras)
ui = fluidPage(
leafletOutput("map")
)
server = function(input,output,session){
output$map = renderLeaflet(
leaflet()%>%
addTiles()%>%
addMeasure(
primaryLengthUnit = "kilometers",
secondaryAreaUnit = FALSE
)%>%
addDrawToolbar(
targetGroup='draw',
editOptions = editToolbarOptions(selectedPathOptions = selectedPathOptions())) %>%
setView(lat = 45, lng = 9, zoom = 3)
)
}
shinyApp(ui,server)
It's very easy because the development version of leaflet.extras
has the function. Let's copy it.
(see: https://github.com/bhaskarvk/leaflet.extras/blob/master/R/drawOptions.R).
Here is what you want.
)%>%
addDrawToolbar(
targetGroup='draw',
editOptions = editToolbarOptions(selectedPathOptions = selectedPathOptions()),
circleOptions = filterNULL(list(shapeOptions = drawShapeOptions(),
repeatMode = F,
showRadius = T,
metric = T,
feet = F,
nautic = F))) %>%