-
Notifications
You must be signed in to change notification settings - Fork 503
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
addPolylines does not support lines broken in several pieces #213
Comments
+1 for this problem. I went to the trouble of creating a minimal example, and so will leave it here for posterity
|
@bhaskarv Not sure what to do about this, but worth thinking about for a minute to see if there's a natural solution. |
If I do this to sp_lines if(length(sp_lines@lines) ==1 && length(sp_lines@lines[[1]]@Lines) >1) {
id <- 0
sp_lines.fix <- sp::SpatialLines(
purrr::map(sp_lines@lines[[1]]@Lines, function(line){
id <<- id + 1
Lines(line,id)
}))
} And plot the sp_lines.fix object it works. Does this work for you ? @jcheng5 The fix is fairly trivial so not sure if this needs to go in Leaflet, or just document it for end user to implement on their own data. |
I'm inclined to just document the workaround, or, use the multiPolyline feature in Leaflet. Maybe for vNext. |
Defi vNext, I would much rather upgrade to Leaflet 1.0 after v1.1 and then go after this. |
This example has two lines identified separately in a
SpatialLines
object and it worksNow with two pieces of a line with the same ID,
addPolylines
only shows the first piece.Getting pieces of lines is usual when computing them (using
rasterToContour
for example).There is probably a way to convert from
to
But I am guessing there is probably something more clever to be done!
NB: given that the code is much of the same, I suspect this bug is also true for polygons which are composed of several sub-polygons.
The text was updated successfully, but these errors were encountered: