-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider adding functionality to addReactiveFeatures #38
Comments
Heads-up @sinclairmichael , argument library(leaflet)
library(leafem)
library(sf)
library(geojsonsf)
fran = mapview::franconia
brew = st_join(mapview::breweries, fran)
leaflet() %>%
addTiles() %>%
addGeoJSON(sf_geojson(fran), group = "fran") %>%
leafem:::addReactiveFeatures(
brew
, bindTo = "fran"
, by = "NUTS_ID"
, on = "click"
, group = "brew"
, style = list(color = "black", fillOpacity = 0.9)
, updateStyle = list(
fillColor = "magenta"
, fillOpacity = 0.6
)
) %>%
addMouseCoordinates() %>%
setView(lng = 10.75, lat = 49.75, zoom = 8) |
Btw, I am also thinking that we probably should add a key-click combination to invoke this functionality to avoid ambiguity with standard click action (popup) of the |
Great. I'll try this out Tomorrow! I'm not sure I understand what you mean.. but if you think it's important then absolutely.
Thanks again.
Get Outlook for Android<https://aka.ms/ghei36>
…________________________________
From: tim-salabim <[email protected]>
Sent: Saturday, February 13, 2021 10:18:54 AM
To: r-spatial/leafem <[email protected]>
Cc: sinclairmichael <[email protected]>; Mention <[email protected]>
Subject: Re: [r-spatial/leafem] Consider adding functionality to addReactiveFeatures (#38)
Btw, I am also thinking that we probably should add a key-click combination to invoke this functionality to avoid ambiguity with standard click action (popup) of the bindTo layer.... What do you think?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#38 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AK2JQ43AI6YR6FGRDBOZES3S6ZGY5ANCNFSM4XNIVQCQ>.
|
popups should now also work, e.g. library(leaflet)
library(leafem)
library(sf)
library(geojsonsf)
fran = mapview::franconia
brew = st_join(mapview::breweries, fran)
options(viewer = NULL)
leaflet() %>%
addTiles() %>%
addGeoJSON(sf_geojson(fran), group = "fran") %>%
leafem:::addReactiveFeatures(
brew
, bindTo = "fran"
, by = "NUTS_ID"
, on = "click"
, group = "brew"
, style = list(color = "black", fillOpacity = 0.9)
, updateStyle = list(
fillColor = "magenta"
, fillOpacity = 0.6
)
, popup = leafpop::popupTable(brew)
) %>%
addMouseCoordinates() %>%
setView(lng = 10.75, lat = 49.75, zoom = 8) What I meant earlier is that I think we should not simply bind the functionality to a mouse click, but require that the user also holds a specific key while clicking, e.g. Ctrl + click to show/hide the reactive layer. |
I understand, that makes sense.
I'll give this a go tomorrow morning!
Get Outlook for Android<https://aka.ms/ghei36>
…________________________________
From: tim-salabim <[email protected]>
Sent: Saturday, February 13, 2021 4:51:15 PM
To: r-spatial/leafem <[email protected]>
Cc: sinclairmichael <[email protected]>; Mention <[email protected]>
Subject: Re: [r-spatial/leafem] Consider adding functionality to addReactiveFeatures (#38)
popups should now also work, e.g.
library(leaflet)
library(leafem)
library(sf)
library(geojsonsf)
fran = mapview::franconia
brew = st_join(mapview::breweries, fran)
options(viewer = NULL)
leaflet() %>%
addTiles() %>%
addGeoJSON(sf_geojson(fran), group = "fran") %>%
leafem:::addReactiveFeatures(
brew
, bindTo = "fran"
, by = "NUTS_ID"
, on = "click"
, group = "brew"
, style = list(color = "black", fillOpacity = 0.9)
, updateStyle = list(
fillColor = "magenta"
, fillOpacity = 0.6
)
, popup = leafpop::popupTable(brew)
) %>%
addMouseCoordinates() %>%
setView(lng = 10.75, lat = 49.75, zoom = 8)
What I meant earlier is that I think we should not simply bind the functionality to a mouse click, but require that the user also holds a specific key while clicking, e.g. Ctrl + click to show/hide the reactive layer.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#38 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AK2JQ43RC3WS575PBUH7C33S62UYHANCNFSM4XNIVQCQ>.
|
Update, reactivity is now bound to pressing (and holding) Ctrl key, e.g. library(leaflet)
library(leafem)
library(sf)
library(geojsonsf)
fran = mapview::franconia
brew = st_join(mapview::breweries, fran)
options(viewer = NULL)
leaflet() %>%
addTiles() %>%
addGeoJSON(sf_geojson(fran), group = "fran") %>%
leafem:::addReactiveFeatures(
brew
, bindTo = "fran"
, by = "NUTS_ID"
, on = "mouseover"
, group = "brew"
, style = list(color = "black", fillOpacity = 0.9)
, updateStyle = list(
fillColor = "magenta"
, fillOpacity = 0.6
)
, popup = leafpop::popupTable(brew)
) %>%
addMouseCoordinates() %>%
setView(lng = 10.75, lat = 49.75, zoom = 8) |
Update: style for the original layer is now properly reset when overlay layer is removed. This means we now have a nice experience for polygon - polygon overlays, e.g. library(leaflet)
library(leafem)
library(sf)
library(geojsonsf)
library(mapview)
library(data.table)
frandt = data.table(franconia)
regions = st_as_sf(
frandt[, .(geometry = st_union(geometry)), by = "district"]
)
leaflet() %>%
addTiles() %>%
addGeoJSON(sf_geojson(regions), group = "regions") %>%
leafem:::addReactiveFeatures(
franconia
, bindTo = "regions"
, by = "district"
, on = "click"
, group = "franconia"
, style = list(color = "black", fillOpacity = 0.3)
, updateStyle = list(
opacity = 0
, fillOpacity = 0
)
, popup = leafpop::popupTable(franconia)
) %>%
addMouseCoordinates() %>%
setView(lng = 10.75, lat = 49.75, zoom = 8) |
Excellent! I will trial this later in the week for a meeting I have to show some interactive results.
Best,
Michael Sinclair
PhD Student | Dept of Natural Resources and Environmental Management
Adjunct Researcher | Natural Resources and Environmental Research Centre
t: +972-5-58832665
e: [email protected]
e: [email protected]
University of Haifa
199 Aba Khushy
Haifa 3498838, Israel
From: tim-salabim<mailto:[email protected]>
Sent: 21 February 2021 11:57
To: r-spatial/leafem<mailto:[email protected]>
Cc: sinclairmichael<mailto:[email protected]>; Mention<mailto:[email protected]>
Subject: Re: [r-spatial/leafem] Consider adding functionality to addReactiveFeatures (#38)
Update: style for the original layer is now properly reset when overlay layer is removed. This means we now have a nice experience for polygon - polygon overlays, e.g.
library(leaflet)
library(leafem)
library(sf)
library(geojsonsf)
library(mapview)
library(data.table)
frandt = data.table(franconia)
regions = st_as_sf(
frandt[, .(geometry = st_union(geometry)), by = "district"]
)
leaflet() %>%
addTiles() %>%
addGeoJSON(sf_geojson(regions), group = "regions") %>%
leafem:::addReactiveFeatures(
franconia
, bindTo = "regions"
, by = "district"
, on = "click"
, group = "franconia"
, style = list(color = "black", fillOpacity = 0.3)
, updateStyle = list(
opacity = 0
, fillOpacity = 0
)
, popup = leafpop::popupTable(franconia)
) %>%
addMouseCoordinates() %>%
setView(lng = 10.75, lat = 49.75, zoom = 8)
[Peek 2021-02-21 12-56]<https://user-images.githubusercontent.com/2826432/108624292-5eae2000-7444-11eb-9561-6de5e5268137.gif>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#38 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AK2JQ4ZISMRN5GU7LXN4PR3TADYMFANCNFSM4XNIVQCQ>.
|
I get this error when I run your code:
Error in leafem:::addReactiveFeatures(., franconia, bindTo = "regions", :
unused arguments (updateStyle = list(opacity = 0, fillOpacity = 0), popup = leafpop::popupTable(franconia))
Any idea? I have remote installed the updated package.
Thanks,
Michael Sinclair
PhD Student | Dept of Natural Resources and Environmental Management
Adjunct Researcher | Natural Resources and Environmental Research Centre
t: +972-5-58832665
e: [email protected]
e: [email protected]
University of Haifa
199 Aba Khushy
Haifa 3498838, Israel
From: tim-salabim<mailto:[email protected]>
Sent: 21 February 2021 11:57
To: r-spatial/leafem<mailto:[email protected]>
Cc: sinclairmichael<mailto:[email protected]>; Mention<mailto:[email protected]>
Subject: Re: [r-spatial/leafem] Consider adding functionality to addReactiveFeatures (#38)
Update: style for the original layer is now properly reset when overlay layer is removed. This means we now have a nice experience for polygon - polygon overlays, e.g.
library(leaflet)
library(leafem)
library(sf)
library(geojsonsf)
library(mapview)
library(data.table)
frandt = data.table(franconia)
regions = st_as_sf(
frandt[, .(geometry = st_union(geometry)), by = "district"]
)
leaflet() %>%
addTiles() %>%
addGeoJSON(sf_geojson(regions), group = "regions") %>%
leafem:::addReactiveFeatures(
franconia
, bindTo = "regions"
, by = "district"
, on = "click"
, group = "franconia"
, style = list(color = "black", fillOpacity = 0.3)
, updateStyle = list(
opacity = 0
, fillOpacity = 0
)
, popup = leafpop::popupTable(franconia)
) %>%
addMouseCoordinates() %>%
setView(lng = 10.75, lat = 49.75, zoom = 8)
[Peek 2021-02-21 12-56]<https://user-images.githubusercontent.com/2826432/108624292-5eae2000-7444-11eb-9561-6de5e5268137.gif>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#38 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AK2JQ4ZISMRN5GU7LXN4PR3TADYMFANCNFSM4XNIVQCQ>.
|
Did you re-install from github? |
I did. It runs but with this error now:
Error in enc2utf8(colnames(x)) : argument is not a character vector
Michael Sinclair
PhD Student | Dept of Natural Resources and Environmental Management
Adjunct Researcher | Natural Resources and Environmental Research Centre
t: +972-5-58832665
e: [email protected]
e: [email protected]
University of Haifa
199 Aba Khushy
Haifa 3498838, Israel
From: tim-salabim<mailto:[email protected]>
Sent: 25 February 2021 15:29
To: r-spatial/leafem<mailto:[email protected]>
Cc: sinclairmichael<mailto:[email protected]>; Mention<mailto:[email protected]>
Subject: Re: [r-spatial/leafem] Consider adding functionality to addReactiveFeatures (#38)
Did you re-install from github?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#38 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AK2JQ47DQO2NCUJWDMMVJ63TAZUE5ANCNFSM4XNIVQCQ>.
|
rstudio/htmltools#97 maybe from this? Is your htmltools up to date? |
Consider an a update_style argument which allows labelling of points and also highlights those points which are selected in the base layer. When we have multiple points selected, displaying many point on the reactive layer, it is not clear which ones they are to deselect them.
The text was updated successfully, but these errors were encountered: