r-spatial / leafgl

R package for fast web gl rendering for leaflet
Other
263 stars 31 forks source link

Can we draw the polygon borders? #3

Open SimonCoulombe opened 5 years ago

SimonCoulombe commented 5 years ago

I've seen this issue on the original leaflet.glify, but I'm not sure how to implement it: https://github.com/robertleeplummerjr/Leaflet.glify/issues/14

cheers!

tim-salabim commented 5 years ago

I am not sure either. I think it would be best if you add your request to the issue you mention above. It would surely be nice to have polygon borders.

SimonCoulombe commented 5 years ago

will do! Oh. and I forgot to thank you for your work on this package. I only found it yesterday and already made my first 60k polygons map. I'm hoping for 1 million now (.canadian postal codes), but I don't want to get my hope to high :)

tim-salabim commented 5 years ago

I think you saw my post about 1.8 mio building footprints on twitter? Depending on polygon comexity you might need to chunk the data. There's also a faster way using data.table described in the inst/experiments folder of this repo.

I am very interested to hear back about any experience with this package so don't be shy to post your experience here.

tim-salabim commented 5 years ago

@SimonCoulombe did you manage to plot the canadian zip codes?

SimonCoulombe commented 5 years ago

Hi Tim, Thanks for following up! I had to steer my time toward other projects, so mapping the postal codes has been on the back burner for a bit. I'll try to get to it when we get back from the holidays.

Merry Christmas (or holidays, whichever suits you better) :)

tim-salabim commented 4 years ago

The upstream repo has a PR that has stalled a little, but maybe this will be added at some stage.

https://github.com/robertleeplummerjr/Leaflet.glify/pull/32

nevilamos commented 4 years ago

Hi Tim, still fairly new to github, trying to follow the outcome of issue#3 drawing borders - I would like to be able to draw just polygon borders with no fill. is this possible? thanks

tim-salabim commented 4 years ago

Yes! You just need to st_cast (assuming you use sf) your polygons to linestrings and then use addGlPolylines

nevilamos commented 4 years ago

Hi thanks for the quick response,

that works as a sort of workaround, however drawing the linestrings will result in different behavour to the leflet drawing polygons with a boundary

Would be wonderful if it could work in the same way it does in addPolygons with ability to have separate colour for fill and line for a polygon.

Thanks for all your great work on this project anyway - At least I can render all my polygons!

On Fri, 29 May 2020 at 00:12, tim-salabim notifications@github.com wrote:

Yes! You just need to st_cast your polygons to linestrings and then use addGlPolylines

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/r-spatial/leafgl/issues/3#issuecomment-635375213, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALKPWC6ARRPN7DN4XBL7BW3RTZWNFANCNFSM4F7SZUNA .

nevilamos commented 4 years ago

I got this how I wanted eventually by drawing the ploygons completely transparent ( so I could still clikc on them to get attributes and also drawing the lines. Would be nice to roll into one as in addPolygons though.

tim-salabim commented 4 years ago

When you use mapview with mapviewOptions(platform = "leafgl") you get both the polygons and the borders. I don't want to make this the default in leafgl, because a fix should not be too far away upstream. I think for making maps "manually" using leaflet et al. it is acceptable to do that one additional step.

I'll leave this open until we have a baked in solution for the polygon borders

dholstius commented 3 years ago

+1 for having borders baked in. HTML size is doubled when adding the polyline borders separately, "on top" of the polygons, via a subsequent call to addGlPolylines(). Guessing this is because all of the geometry is duplicated!

Thank you for all your hard work on this great library!

tim-salabim commented 3 years ago

@dholstius yes the reason for doubling the size is that everything, especially the geometry data, is included twice. If I'm not mistaken, there is already a PR in the upstream repo to allow for drawing borders without having to add the data twice. So the current implementation here is a temporal workaround until we get that functionality cascaded down from upstream Leaflet.glify.