r-spatial / mapedit

Interactive editing of spatial data in R
https://www.r-spatial.org/r/2019/03/31/mapedit_leafpm.html
Other
218 stars 33 forks source link

label argument for selectFeatures and editFeatures #55

Closed timelyportfolio closed 7 years ago

timelyportfolio commented 7 years ago

53

selectFeatures

library(mapview)
library(mapedit)

selectFeatures(franconia, label=~NAME_ASCI)
selectFeatures(franconia, label=~NAME_ASCI, map=leaflet() %>% addTiles())
selectFeatures(breweries, label=~brewery)

editFeatures

library(mapview)
library(mapedit)

editFeatures(franconia[1:4,], label=~NAME_ASCI)
editFeatures(franconia[1:4,], label=~NAME_ASCI, map=leaflet() %>% addTiles())
editFeatures(breweries, label=~brewery)

In editFeatures, the label will partially cover the Leaflet.draw instructions. Should we change the offset or direction with labelOptions?

image

tim-salabim commented 7 years ago

Sorry been away on academic duty from my past. I will test this tomorrow and report back

tim-salabim commented 7 years ago

@timelyportfolio this works as expected. Regarding the label position, I think we should change both offset and position, my favorite would be to have them on top of the features. What do you think?

timelyportfolio commented 7 years ago

Thanks for testing and more importantly the idea. labelOptions are not accessible with addFeatures, so I will need to determine a different strategy for changing the offset. I hope to have something up within an hour.

tim-salabim commented 7 years ago

They should be accessible... Are you sure?

tim-salabim commented 7 years ago
leaflet() %>% 
  addTiles() %>% 
  addFeatures(franconia, label = as.character(franconia$district),
                       labelOptions = labelOptions(direction = "top",
                                                                     offset = c(0, -40)))

works for me

timelyportfolio commented 7 years ago

@tim-salabim, struck through my oversight nearly immediately, but chatting over github issues has some latency :) Working on optimizing position for different types of features.

timelyportfolio commented 7 years ago

@tim-salabim if you are still on, does offset work for you? I cannot get it to have any impact when using with direction="top".

tim-salabim commented 7 years ago

yes it does, the -40 in the example above means it is placed above the mouse cursor

tim-salabim commented 7 years ago

label

timelyportfolio commented 7 years ago

✔️ Since the default is 12,-15 I was not using enough to provide easily seen visual change. I think top with 0,40 is good, but on points doesn't look good. Not sure it is worth burning a lot of time trying to perfect.

tim-salabim commented 7 years ago

I agree, this is a minor aesthetic issue

timelyportfolio commented 7 years ago

Ok, then I just added a NEWS item, so I think it should be ready to push the button.