Skip to content
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

Label argument not working #78

Open
laldew opened this issue Sep 20, 2022 · 5 comments · May be fixed by #95
Open

Label argument not working #78

laldew opened this issue Sep 20, 2022 · 5 comments · May be fixed by #95

Comments

@laldew
Copy link

laldew commented Sep 20, 2022

Thanks for your work on this library!

I cannot figure out how to get a label to display on hover. Please see example below:

if (interactive()) {
    library(leaflet)
    library(leafgl)
    library(sf)
    
    gadm = st_as_sf(gadmCHE)
    gadm = st_cast(gadm, "POLYGON")
    cols = grey.colors(nrow(gadm))
    
    leaflet() %>%
        addProviderTiles(provider = providers$CartoDB.DarkMatter) %>%
        addGlPolygons(data = gadm, color = cols, popup = TRUE, label=gadm$NAME_1)
}
@trafficonese
Copy link
Collaborator

There is currently no hover event, so labels wont work.

@xiaofanliang
Copy link

Would love to be able to have the hover label!!

@trafficonese
Copy link
Collaborator

trafficonese commented Jun 3, 2024

Apparently with commit b469ee6 labels should be working..
But it is not working for me and I dont think it should aswell, since the data only has the property id, because we remove all other columns in the R methods.

@tim-salabim Did I break something with my latest merge? It's weird, as at some point I also had labels working but now I am getting this error, which makes sense since the features only have the property id.

Cannot read properties of undefined (reading 'toString')

@tim-salabim
Copy link
Member

@tim-salabim Did I break something with my latest merge?

Not sure. I can look into this at some stage, but probably not before next week

@trafficonese
Copy link
Collaborator

The labels currently only work, when popup = TRUE as then we dont remove any data columns.
We have this which also doesnt really make sense or?

else if (isTRUE(popup)) {
    data = data[, popup]
  }

I am thinking of using labels <- leaflet::evalFormula(label, data) before the popup part and pass this vector to Glify, then we can use formulas too and the interface is identical for lines/points/polygons and also to leaflet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants