r-spatial / leafpm Goto Github PK
View Code? Open in Web Editor NEWLeaflet.pm for R Leaflet
License: Other
Leaflet.pm for R Leaflet
License: Other
@edzer would it be possible to add leafpm
to r-spatial Travis? Thanks so much.
Hi,
I'm one of the maintainer of Leaflet-Geoman (earlier Leaflet.pm) and we want to ask what do you need to move it from Leaflet.pm to the newest version Leaflet-Geoman?
We self never touched with R so we can only help on the Library side.
I see that the colors (both the hint line and the final object) for the polyline can be modified:
pmDrawOptions( templineStyle = list(color = "#000"),
hintlineStyle = list(color = "#000", dashArray = "5,5"))
Would it be possible to modify the same set of attributes for the rectangles and circles? It would work for me if the hintlineStyle
and templineStyle
modified all the drawn objects.
There is a similar feature using leaflet.extras...
leaflet.extras::addDrawToolbar(
polygonOptions = filterNULL(list(shapeOptions = drawShapeOptions(color = "red",
fillOpacity = 1,
fillColor = "yellow",
weight = 20),
repeatMode = F,
showRadius = T,
metric = T,
feet = F,
nautic = F)))
...but I was hoping to use leafpm.
Related to r-spatial/mapedit#113. Code to reproduce.
library(leaflet)
library(mapview)
library(leafpm)
mapview(breweries)@map %>% addPmToolbar(targetGroup ="breweries")
mapview(trails[1:2,])@map %>% addPmToolbar(targetGroup ="trails[1:2, ]")
Other edit modes are supported and only apply per feature but delete removes everything.
I found that when editing a shape that was added to the leaflet
instance (not drawn with the toolbar) can be edited, but the edited shape does not show up as a reactive value in a shiny app. Am I doing something wrong here?
Example app below:
pmToolbar
, but nothing shows up in input
(see Debug tab for all reactives).main_map_draw_edited_features
).I also noticed that if we do the following: leaflet() %>% addPolygons(data = existing_shape) %>% addPmToolbar()
, the shape is not editable, but if we do leaflet() %>% addPmToolbar() %>% addPolygons(data = existing_shape)
, the shape does become editable. Perhaps this is a feature, not a bug?
existing_shape <- structure(list(structure(list(list(structure(c(6.56404800296482,
6.62588800302508, 6.5413740029429, 6.53793800293931, 6.56267400296326,
6.56404800296482, 53.1583820045482, 53.1620880045473, 53.1703200045554,
53.1534410045469, 53.1423220045401, 53.1583820045482), .Dim = c(6L,
2L)))), class = c("XY", "MULTIPOLYGON", "sfg"))), n_empty = 0L, crs = structure(list(
epsg = 4326L, proj4string = "+proj=longlat +datum=WGS84 +no_defs"), class = "crs"), class = c("sfc_MULTIPOLYGON",
"sfc"), precision = 0, bbox = structure(c(xmin = 6.53793800293931,
ymin = 53.1423220045401, xmax = 6.62588800302508, ymax = 53.1703200045554
), class = "bbox"))
library(shiny)
library(leafpm)
library(shiny)
ui <- fluidPage(
tabsetPanel(
tabPanel("Map",
leafletOutput("main_map")
),
tabPanel("Debug",
verbatimTextOutput("debug_out")
)
)
)
server <- function(input, output, session) {
output$debug_out <- renderPrint(reactiveValuesToList(input))
output$main_map <- renderLeaflet({
leaflet() %>%
leafpm::addPmToolbar(
drawOptions = pmDrawOptions(snappable = FALSE),
toolbarOptions = pmToolbarOptions(
editMode = TRUE,
drawMarker = TRUE,
drawPolygon = TRUE,
drawCircle = FALSE,
drawPolyline = FALSE,
drawRectangle = FALSE,
cutPolygon = FALSE,
position = "bottomleft"
)
) %>%
addPolygons(data = existing_shape)
})
}
shinyApp(ui, server)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.