Skip to content

'initBaseMaps' and 'mode = "click"' for selectFeatures #123

@joshualerickson

Description

@joshualerickson
library(mapedit)
#> Warning: multiple methods tables found for 'crop'
#> Warning: multiple methods tables found for 'extend'
#> Warning: replacing previous import 'DT::dataTableOutput' by
#> 'shiny::dataTableOutput' when loading 'mapedit'
#> Warning: replacing previous import 'DT::renderDataTable' by
#> 'shiny::renderDataTable' when loading 'mapedit'
#> Registered S3 methods overwritten by 'stars':
#>   method             from
#>   st_bbox.SpatRaster sf  
#>   st_crs.SpatRaster  sf
library(sf)
#> Linking to GEOS 3.9.1, GDAL 3.2.1, PROJ 7.2.1; sf_use_s2() is TRUE

pts <- rbind(list(matrix(c(170800,172000, 5410500, 5410400),2)),
              list(matrix(c(170810,172010, 5410580, 5410400),2)))

line <- lapply(pts, FUN = function(x)sf::st_as_sf(sf::st_sfc(sf::st_linestring(x), crs = 32612)))
line <- st_as_sf(bind_rows(line))

#class
class(line)
#> [1] "sf"         "data.frame"

# especially easy with selectFeatures
selectFeatures(line)
#> Error in initBaseMaps(map.types, canvas = canvas, viewer.suppress = viewer.suppress): could not find function "initBaseMaps"

Looks like something with the mapview internal function initBaseMaps. Looked into it and if you add it to the mapview_init.R file it seems to fix the problem for the most recent dev version. However, when using a linestring it doesn't work for mode = 'click'... Looked into the selectMod and selectMap functions but couldn't find the mix-up? I'm not sure if it has to do with the handlers in the JS in particular to 'linestrings' because it works fine with polygons and points 🤷‍♂️ so not sure. Thanks!
Created on 2022-04-04 by the reprex package (v2.0.0)

Session info
sessioninfo::session_info()
#> - Session info ---------------------------------------------------------------
#>  setting  value                       
#>  version  R version 4.0.5 (2021-03-31)
#>  os       Windows 10 x64              
#>  system   x86_64, mingw32             
#>  ui       RTerm                       
#>  language (EN)                        
#>  collate  English_United States.1252  
#>  ctype    English_United States.1252  
#>  tz       America/Denver              
#>  date     2022-04-04                  
#> 
#> - Packages -------------------------------------------------------------------
#>  package      * version    date       lib source                            
#>  abind          1.4-5      2016-07-21 [1] CRAN (R 4.0.3)                    
#>  assertthat     0.2.1      2019-03-21 [1] CRAN (R 4.0.5)                    
#>  backports      1.2.1      2020-12-09 [1] CRAN (R 4.0.3)                    
#>  base64enc      0.1-3      2015-07-28 [1] CRAN (R 4.0.3)                    
#>  brew           1.0-6      2011-04-13 [1] CRAN (R 4.0.3)                    
#>  bslib          0.3.1      2021-10-06 [1] CRAN (R 4.0.5)                    
#>  class          7.3-18     2021-01-24 [1] CRAN (R 4.0.5)                    
#>  classInt       0.4-3      2020-04-07 [1] CRAN (R 4.0.5)                    
#>  cli            3.2.0      2022-02-14 [1] CRAN (R 4.0.5)                    
#>  codetools      0.2-18     2020-11-04 [1] CRAN (R 4.0.5)                    
#>  colorspace     2.0-2      2021-06-24 [1] CRAN (R 4.0.5)                    
#>  crayon         1.4.2      2021-10-29 [1] CRAN (R 4.0.5)                    
#>  crosstalk      1.2.0      2021-11-04 [1] CRAN (R 4.0.5)                    
#>  DBI            1.1.2      2021-12-20 [1] CRAN (R 4.0.5)                    
#>  dichromat      2.0-0      2013-01-24 [1] CRAN (R 4.0.3)                    
#>  digest         0.6.29     2021-12-01 [1] CRAN (R 4.0.5)                    
#>  dplyr          1.0.8      2022-02-08 [1] CRAN (R 4.0.5)                    
#>  DT             0.18       2021-04-14 [1] CRAN (R 4.0.5)                    
#>  e1071          1.7-9      2021-09-16 [1] CRAN (R 4.0.5)                    
#>  ellipsis       0.3.2      2021-04-29 [1] CRAN (R 4.0.5)                    
#>  evaluate       0.14       2019-05-28 [1] CRAN (R 4.0.5)                    
#>  fansi          0.5.0      2021-05-25 [1] CRAN (R 4.0.5)                    
#>  fastmap        1.1.0      2021-01-25 [1] CRAN (R 4.0.5)                    
#>  fs             1.5.0      2020-07-31 [1] CRAN (R 4.0.5)                    
#>  generics       0.1.0      2020-10-31 [1] CRAN (R 4.0.5)                    
#>  glue           1.6.0      2021-12-17 [1] CRAN (R 4.0.5)                    
#>  highr          0.9        2021-04-16 [1] CRAN (R 4.0.5)                    
#>  htmltools      0.5.2      2021-08-25 [1] CRAN (R 4.0.5)                    
#>  htmlwidgets    1.5.4      2021-09-08 [1] CRAN (R 4.0.5)                    
#>  httpuv         1.5.5      2021-01-13 [1] CRAN (R 4.0.5)                    
#>  jquerylib      0.1.4      2021-04-26 [1] CRAN (R 4.0.5)                    
#>  jsonlite       1.7.2      2020-12-09 [1] CRAN (R 4.0.5)                    
#>  KernSmooth     2.23-18    2020-10-29 [1] CRAN (R 4.0.5)                    
#>  knitr          1.37       2021-12-16 [1] CRAN (R 4.0.5)                    
#>  later          1.1.0.1    2020-06-05 [1] CRAN (R 4.0.5)                    
#>  lattice        0.20-41    2020-04-02 [1] CRAN (R 4.0.5)                    
#>  leafem         0.1.6      2021-05-24 [1] CRAN (R 4.0.5)                    
#>  leaflet        2.0.4.1    2021-01-07 [1] CRAN (R 4.0.5)                    
#>  leafpop        0.0.6      2020-09-22 [1] CRAN (R 4.0.5)                    
#>  lifecycle      1.0.1      2021-09-24 [1] CRAN (R 4.0.5)                    
#>  lwgeom         0.2-6      2021-04-02 [1] CRAN (R 4.0.5)                    
#>  magrittr       2.0.2      2022-01-26 [1] CRAN (R 4.0.5)                    
#>  mapedit      * 0.6.1.9002 2022-03-31 [1] Github (r-spatial/mapedit@35ae8cc)
#>  mapview        2.10.0     2021-06-05 [1] CRAN (R 4.0.5)                    
#>  mime           0.12       2021-09-28 [1] CRAN (R 4.0.5)                    
#>  munsell        0.5.0      2018-06-12 [1] CRAN (R 4.0.5)                    
#>  pillar         1.6.4      2021-10-18 [1] CRAN (R 4.0.5)                    
#>  pkgconfig      2.0.3      2019-09-22 [1] CRAN (R 4.0.5)                    
#>  png            0.1-7      2013-12-03 [1] CRAN (R 4.0.3)                    
#>  promises       1.2.0.1    2021-02-11 [1] CRAN (R 4.0.5)                    
#>  proxy          0.4-26     2021-06-07 [1] CRAN (R 4.0.5)                    
#>  purrr          0.3.4      2020-04-17 [1] CRAN (R 4.0.5)                    
#>  R6             2.5.1      2021-08-19 [1] CRAN (R 4.0.5)                    
#>  raster         3.5-11     2021-12-23 [1] CRAN (R 4.0.5)                    
#>  RColorBrewer   1.1-2      2014-12-07 [1] CRAN (R 4.0.3)                    
#>  Rcpp           1.0.7      2021-07-07 [1] CRAN (R 4.0.5)                    
#>  reprex         2.0.0      2021-04-02 [1] CRAN (R 4.0.5)                    
#>  rlang          1.0.1      2022-02-03 [1] CRAN (R 4.0.5)                    
#>  rmarkdown      2.11       2021-09-14 [1] CRAN (R 4.0.5)                    
#>  rstudioapi     0.13       2020-11-12 [1] CRAN (R 4.0.5)                    
#>  sass           0.4.0      2021-05-12 [1] CRAN (R 4.0.5)                    
#>  satellite      1.0.2      2019-12-09 [1] CRAN (R 4.0.5)                    
#>  scales         1.1.1      2020-05-11 [1] CRAN (R 4.0.5)                    
#>  sessioninfo    1.1.1      2018-11-05 [1] CRAN (R 4.0.5)                    
#>  sf           * 1.0-5      2021-12-17 [1] CRAN (R 4.0.5)                    
#>  shiny          1.6.0      2021-01-25 [1] CRAN (R 4.0.5)                    
#>  shinyWidgets   0.6.0      2021-03-15 [1] CRAN (R 4.0.5)                    
#>  sp             1.4-6      2021-11-14 [1] CRAN (R 4.0.5)                    
#>  stars          0.5-2      2021-03-17 [1] CRAN (R 4.0.5)                    
#>  stringi        1.7.6      2021-11-29 [1] CRAN (R 4.0.5)                    
#>  stringr        1.4.0      2019-02-10 [1] CRAN (R 4.0.5)                    
#>  styler         1.4.1      2021-03-30 [1] CRAN (R 4.0.5)                    
#>  svglite        2.0.0      2021-02-20 [1] CRAN (R 4.0.5)                    
#>  systemfonts    1.0.3      2021-10-13 [1] CRAN (R 4.0.5)                    
#>  terra          1.5-17     2022-01-30 [1] CRAN (R 4.0.5)                    
#>  tibble         3.1.6      2021-11-07 [1] CRAN (R 4.0.5)                    
#>  tidyselect     1.1.1      2021-04-30 [1] CRAN (R 4.0.5)                    
#>  tmaptools      3.1-1      2021-01-19 [1] CRAN (R 4.0.5)                    
#>  units          0.7-2      2021-06-08 [1] CRAN (R 4.0.5)                    
#>  utf8           1.2.2      2021-07-24 [1] CRAN (R 4.0.5)                    
#>  uuid           0.1-4      2020-02-26 [1] CRAN (R 4.0.3)                    
#>  vctrs          0.3.8      2021-04-29 [1] CRAN (R 4.0.5)                    
#>  viridisLite    0.4.0      2021-04-13 [1] CRAN (R 4.0.5)                    
#>  webshot        0.5.2      2019-11-22 [1] CRAN (R 4.0.5)                    
#>  withr          2.4.3      2021-11-30 [1] CRAN (R 4.0.5)                    
#>  xfun           0.29       2021-12-14 [1] CRAN (R 4.0.5)                    
#>  XML            3.99-0.6   2021-03-16 [1] CRAN (R 4.0.4)                    
#>  xtable         1.8-4      2019-04-21 [1] CRAN (R 4.0.5)                    
#>  yaml           2.2.1      2020-02-01 [1] CRAN (R 4.0.4)                    
#> 
#> [1] C:/Users/joshualerickson/Documents/R/R-4.0.5/library

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions