Skip to content

Commit

Permalink
Merge pull request #99 from JoshOBrien/PR-use-leafem
Browse files Browse the repository at this point in the history
Calls to addFeatures() & addHomeButton() should use leafem package
  • Loading branch information
tim-salabim authored Jun 1, 2019
2 parents 740096b + 713e653 commit c3130ca
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Imports:
htmltools (>= 0.3),
htmlwidgets,
jsonlite,
leafem,
leaflet (>= 2.0.1),
leaflet.extras (>= 1.0),
leafpm,
Expand Down
8 changes: 4 additions & 4 deletions R/edit.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Interactively Edit a Map
#'
#' @param x \code{leaflet} or \code{mapview} map to edit
#' @param ... other arguments for \code{mapview::addFeatures()} when
#' @param ... other arguments for \code{leafem::addFeatures()} when
#' using \code{editMap.NULL} or \code{selectFeatures}
#'
#' @return \code{sf} simple features or \code{GeoJSON}
Expand Down Expand Up @@ -241,7 +241,7 @@ editFeatures.sf = function(
if (is.null(map)) {
x = mapview:::checkAdjustProjection(x)
map = mapview::mapview()@map
map = mapview::addFeatures(
map = leafem::addFeatures(
map, data=x, layerId=~x$edit_id,
label=label,
labelOptions = leaflet::labelOptions(direction="top", offset=c(0,-40)),
Expand All @@ -255,12 +255,12 @@ editFeatures.sf = function(
lng2 = ext[2],
lat2 = ext[4]
)
map = mapview::addHomeButton(map = map, ext = ext)
map = leafem::addHomeButton(map = map, ext = ext)
} else {
if(inherits(map, "mapview")) {
map = map@map
}
map = mapview::addFeatures(
map = leafem::addFeatures(
map, data=x, layerId=~x$edit_id,
label=label,
labelOptions = leaflet::labelOptions(direction="top", offset=c(0,-40)),
Expand Down
6 changes: 3 additions & 3 deletions R/select.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ selectFeatures.sf = function(

if (is.null(map)) {
map = mapview::mapView(...)@map
map = mapview::addFeatures(
map = leafem::addFeatures(
map, data = x, layerId = ~x$edit_id, label = label, ...
)
ext = mapview:::createExtent(x)
Expand All @@ -77,12 +77,12 @@ selectFeatures.sf = function(
lng2 = ext[2],
lat2 = ext[4]
)
map = mapview::addHomeButton(map = map, ext = ext)
map = leafem::addHomeButton(map = map, ext = ext)
} else {
if(inherits(map, "mapview")) {
map = map@map
}
map = mapview::addFeatures(
map = leafem::addFeatures(
map, data=x, layerId=~x$edit_id, label=label
)
}
Expand Down
2 changes: 1 addition & 1 deletion man/editMap.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c3130ca

Please sign in to comment.