r-spatial / mapview

Interactive viewing of spatial data in R
https://r-spatial.github.io/mapview/
GNU General Public License v3.0
517 stars 91 forks source link

SpatialLines with MultiLines are not all shown #18

Closed edzer closed 8 years ago

edzer commented 8 years ago

Try:

library(trajectories)
data(storms)
x = as(storms, "SpatialLinesDataFrame")
plot(x)
library(mapview)
mapview(x)

it seems that only the first Line of a Lines object is plotted.

fdetsch commented 8 years ago

The problem is obviously related with addPolylines from leaflet that seemingly drops all but the first continuous sub-line in an otherwise discontinuous (i.e., segmented) line. For example,

leaflet(x) %>% addTiles() %>% addPolylines()

behaves similar to mapview(x). I implemented a temporary workaround to display all line segments regardless of whether or not the line is broken. Edzer, since I assume you are familiar with the storms dataset, could you please compile the latest version of the 'devel' branch (1.0.11) and evaluate if the output of mapview(x), particularly the pop-up assignment, now looks correct? Please note that this currently works with burst = FALSE only.

edzer commented 8 years ago

Thanks! For SpatialLinesDataFrame it now works, for SpatialLines it doesn't. Shall I write an issue for leaflet?

fdetsch commented 8 years ago

It shouldn't cost too much effort to transfer this approach to SpatialLines. Since the problem arises from addPolylines, however, I think that it would be desirable if this could be handled from the leaflet side in the long run (not least because there are far more leaflet users out there).

edzer commented 8 years ago

It's already there: https://github.com/rstudio/leaflet/issues/213

fdetsch commented 8 years ago

Just for the record, mapview support for SpatialLines is now enabled as well.