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

Polygons are deformed #93

Open
cschuster89 opened this issue Mar 22, 2024 · 7 comments
Open

Polygons are deformed #93

cschuster89 opened this issue Mar 22, 2024 · 7 comments
Labels
upstream needs to be adressed in Leaflet.Glify

Comments

@cschuster89
Copy link

Hi,
first of all I would like to thank you for the great libary, which significantly increases the performance of my maps.

Unfortunately, I have a small problem with the display of my polygons.

Map without LeafGL:

image

Map section with LeafGL:

image

The code I'm using looks like:

building <- building %>% addPolygons(data = filtered_buildings,
                                           color = colors_building[i],
                                           fillColor = colors_building[i],
                                           fillOpacity = 0.7,
                                           highlightOptions = highlightOptions(color = "white", weight = 2,
                                                                               bringToFront = TRUE),
                                           popup = ~paste0("Some popup Options"))

And when I'm using leafgl I just change it to "addGlPolygons" and use "leafglOutput" instead of my "leafletOutput".

Also, my highlightOptions don't work anymore when using addGlPolygons. Is there a way to make them work?

Thanks in advance!

@trafficonese
Copy link
Collaborator

This is still a problem in the underlying library
robertleeplummerjr/Leaflet.glify#137

@cschuster89
Copy link
Author

Ok, I see. Thanks for the quick reply and the reference to the underlying problem.

@trafficonese
Copy link
Collaborator

No worries :) but let's keep it open, as it's still a bug in this library aswell.

@trafficonese trafficonese reopened this Mar 22, 2024
@RayLarone
Copy link

RayLarone commented Mar 23, 2024

I have an open pull request on the leaflet.glify repo which should solve this issue

robertleeplummerjr/Leaflet.glify#138

Until this pull request gets reviewed, I have a fork of the leafgl package with this fix implemented.
This works on my system, although I forked it a while ago so can't guarantee it will be free from issues. Try removing the current leafgl package and run the following code.

install.pacakages("devtools")
devtools::install_github("RayLarone/leafgl")

@cschuster89
Copy link
Author

Awesome. It works great for me. It seems to be a bit slower, but the performance is still good for several hundred thousand polygons.

Just out of interest: What exactly did you change and where? Did you move the origin of the map to the center of the displayed area?

@RayLarone
Copy link

That's good. Tbh, the performance difference really should be negligible. I may have added some other things to the fork which may be affecting performance, though I can't quite remember.

You can see the changes made and explanations in the pull request links above. Essentially, normalising some of the pixel coordinates around (0, 0) in the underlying library seems to fix the issue.

@cschuster89
Copy link
Author

Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream needs to be adressed in Leaflet.Glify
Projects
None yet
Development

No branches or pull requests

3 participants