Git Product home page Git Product logo

leafpm's People

Contributors

tim-salabim avatar timelyportfolio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

leafpm's Issues

add travis

@edzer would it be possible to add leafpm to r-spatial Travis? Thanks so much.

Allow changing of color for leafpm drawn rectangles and circles?

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.

Deleting one feature in layer deletes all

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.

Editing existing shape does not pass reactives to Shiny

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:

  • An existing polygon is plotted on the map, we can edit this by clicking the edit button of the pmToolbar, but nothing shows up in input (see Debug tab for all reactives).
  • If we draw a new polygon, and start editing it, it does show up as a bunch of reactive values (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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.