Indeed, the mistake here is using leaflet() %>% instead of leaflet(random_event) %>% which then works with both versions.
I still thing this is a minor bug. But feel free to disregard it. I will try to improve the SO issue, so that anyone who does the same in the future understands why it is not a bug. Although, with your explanation it is definitely more informative.
The text was updated successfully, but these errors were encountered:
Let me also note that this error basically means, "you used the formula syntax which implies you gave us some data--but I didn't find any data". I suspect the fact that you're seeing this with addLegend means your map doesn't have any data (i.e. you didn't pass any data to leaflet()), only a specific marker/shape layer was given data. (It looks like addLegend doesn't itself have an explicit data parameter, which is probably an oversight in the library.)
Providing
addLegendwith values in the fashionvalues = df$variablerather thanvalues =~variablesolves an occurrence of the error:which happens if
variablehas NA's.I don't see why isn't this the default behaviour.
source:
https://stackoverflow.com/a/32011289/3494126
p.s. for instance, just following this official tutorial with my data I produced the abovementioned error.
Ok, @jcheng5 thanks for the explanation, now I can produce a working/non-working example:
Indeed, the mistake here is using
leaflet() %>%instead ofleaflet(random_event) %>%which then works with both versions.I still thing this is a minor bug. But feel free to disregard it. I will try to improve the SO issue, so that anyone who does the same in the future understands why it is not a bug. Although, with your explanation it is definitely more informative.
The text was updated successfully, but these errors were encountered: