mapedit and leaflet.js > 1.0

[This article was first published on r-spatial, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

[view raw

Back in September 2016, leaflet.js went 1.0 (see Meet Leaflet
) 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.

screenshot of Barret Schloerke commit On May
10, 2018, Barret posted Leaflet
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

In this post, we will highlight the next steps for mapedit in order of

  1. feature attribute editing

  2. geojson precision

  3. multiline string editing

  4. crosstalk integration

  5. 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


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

install.packages(c("sf", "leaflet", "leaflet.extras", "mapview", "mapedit"))

Feature Attribute Editing

mapedit launched with three objectives:

  1. drawing, editing, and deleting features,

  2. selecting and querying of features and map regions,

  3. editing attributes.

So far, mapedit has focused on 1 and 2 with only a very quick proof of
concept shown in mapedit Intro: Ediiting

building on top of from Tom

screenshot of integrated in

Rather than build on top of, 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
reported in
For complete support of sf, mapedit should work with
multilinestring, so we have promoted this to issue

Crosstalk Integration

Mike Treglia tweeted an interesting use case for mapedit with

We welcomed the challenge and responded with this
crosstalking mapedit/leaflet with Plotly and DT.

screenshot of integrated in shiny

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
. 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
and webinar
Scaling Shiny apps with async
No promises here, but async would be very nice for mapedit.

Conclusion and Thanks

As we progress towards these goals, we will post on, 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.

To leave a comment for the author, please follow the link and comment on their blog: r-spatial. 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.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)