r-spatial / discuss

a discussion repository: raise issues, or contribute!
54 stars 12 forks source link

leafpm draggable argument seems broken #64

Open victorcazalis opened 2 months ago

victorcazalis commented 2 months ago

Hi,

I hope this is the good place to post an issue on leafpm options. I'm trying to allow editing a polygon but not drag it around, I thought that the draggable argument in pmEditOptions() would do it but it is not working. You can see in the reprex below that you can edit the polygon in South America (called MyEditablePolyg) but not the one in the North (MyFixPolyg), but that you can drag the South polygon although draggable is set to F. Just to check that pmEditOptions was working well with this polygon I changed the snap distance and this argument is applied. Is it that the draggable argument is broken or am I missing something?

Thanks for all the great work on r-spatial packages! Best, Victor

Reprex:

library(leaflet)
library(leafpm)
library(sf)

MyEditablePolyg <- st_polygon(list(matrix( c(-90,-56, -80,-20, -6,-56, -90,-56) , byrow=T, ncol=2))) %>% st_sfc(.)
MyFixPolyg <- st_polygon(list(matrix( c(-90,56, -80,20, -6,56, -90,56) , byrow=T, ncol=2))) %>% st_sfc(.)

LEAF <- leaflet() %>%
  addTiles()  %>%
  addPolygons(data=MyEditablePolyg, group="editable") %>%
  addPolygons(data=MyFixPolyg, group="fix") %>%
  leafpm::addPmToolbar(targetGroup="editable", editOptions = pmEditOptions(draggable=F, snapDistance=200), toolbarOptions = pmToolbarOptions(drawMarker=T, drawPolygon=T, drawPolyline=F, drawCircle=F, drawRectangle=F, removalMode=F, cutPolygon=F, editMode=T))

LEAF
tim-salabim commented 2 months ago

@timelyportfolio is this intended behaviour?

victorcazalis commented 1 month ago

Just a quick addition: it would be a fine solution to just be able to remove the "drag" button from the toolbar (so that nothing can be dragged), but I don't think it's possible yet.