mapedit and leaflet.js > 1.0
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
- Install/Update
- Feature Attribute Editing
- Geojson Precision
- Mulitlinestring Editing
- Crosstalk Integration
- Shiny async
- Conclusion and Thanks
Back in September 2016, leaflet.js went 1.0
(see Meet Leaflet
1) with a
massive changelog from 0.7.0
released three years earlier. Meanwhile,
the Leaflet R ecosystem had grown to be very powerful, but also
extremely interwoven and quite complex with significant efforts from Joe
Cheng and the RStudio team on leaflet core, Bhaskar Karambelkar on
leaflet.extras
, Tim
Appelhans on mapview
, and many
other open source contributors. Upgrading Leaflet R to leaflet.js >
1.0 would prove to be a massive undertaking. The mapedit
team devoted
some RConsortium hours to launching the effort, but the entire effort
proved well beyond the scope of this initial contribution. Fortunately
for the R geospatial community, RStudio very generously provided Barret
Schloerke to complete the daunting remaining tasks.
On May
10, 2018, Barret posted Leaflet
2.0.0 on the
RStudio blog with not only an upgrade to leaflet.js > 1.0 but also a
full upgrade to all leaflet.extras
dependencies and very important
infrastructure improvements including a test suite to more easily keep
up with a quicker leaflet.js release cadence.
mapedit
is entirely dependent on Leaflet, so we postponed activity on
mapedit
until the new Leaflet R release. We are pleased to announce
that mapedit
is entirely compatible with the new Leaflet and even more
pleased to get back to work implementing new features and tackling
issues.
In this post, we will highlight the next steps for mapedit
in order of
priority:
-
feature attribute editing
-
geojson precision
-
multiline string editing
-
crosstalk integration
-
shiny async integration.
We cannot stress enough that the success of achieving these depends greatly on feedback and ideas from the geospatial community, so we highly encourage participation at issues.
Install/Update
As mentioned a lot has changed recently, so we recommend updating
leaflet
, leaflet.extras
, mapview
, and mapedit
. The newest sf
is not required, but while we are at it, we should probably update it
also.
install.packages(c("sf", "leaflet", "leaflet.extras", "mapview", "mapedit"))
Feature Attribute Editing
mapedit
launched with three objectives:
-
drawing, editing, and deleting features,
-
selecting and querying of features and map regions,
-
editing attributes.
So far, mapedit
has focused on 1 and 2 with only a very quick proof of
concept shown in mapedit Intro: Ediiting
Attributes
building on top of geojson.io from Tom
Macwright.
Rather than build on top of geojson.io, we would like to tightly
integrate attribute editing into mapedit
. We will track progress on
this issue and would
love your participation.
Geojson Precision
Robin Lovelace discovered that at leaflet zoom level > 17 we lose coordinate precision. Of course, this is not good enough, so we will prioritize a fix as discussed in issue. Hopefully, this leaflet.js pull request will make this fix fairly straightforward.
Mulitlinestring Editing
Leaflet.js and multilinestrings don’t get along as Tim
Appelhans reported in
issue.
For complete support of sf
, mapedit
should work with
multilinestring, so we have promoted this to issue
62.
Crosstalk Integration
Mike Treglia tweeted an interesting use case for mapedit
with
crosstalk
.
want to make interactive scatterplot and map (#GIS) in #rstats – ideally where hovering over point/polygon in map highlights corresponding one in scatterplot, & vice-versa. Favorite examples w/ code? thinking of leaflet/plotly/crosstalk probably, but open to alternatives
— Mike Treglia (@MikeTreglia) December 9, 2017
We welcomed the challenge and responded with this example crosstalking mapedit/leaflet with Plotly and DT.
While the example mostly works, there is far too high a burden on the
user. We will try to reduce this down to a couple of lines of code.
Issue 72 will track
our progress. mapedit
will remain targeted toward Shiny contexts, so
this effort will focus on crosstalk with
Shiny. This plumbing
for crosstalk in mapedit
should provide a foundation for things like
polygon selection in leaflet without Shiny.
Shiny async
RStudio added async support in Shiny as described in the post Shiny
1.1.0: Scaling Shiny with
async and webinar
Scaling Shiny apps with async
programming.
No promises here, but async would be very nice for mapedit
.
Conclusion and Thanks
As we progress towards these goals, we will post on
r-spatial.org, and we would love your help..
mapedit
and many of its dependency packages are funded by the
RConsortium. Thanks so much to all
those who have contributed to this fantastic organization. Also, thanks
to all those open source contributors in the R community.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.