diff --git a/.Rbuildignore b/.Rbuildignore
index 5baf76052..acd7babb9 100644
--- a/.Rbuildignore
+++ b/.Rbuildignore
@@ -13,3 +13,14 @@
^package\.json$
^node_modules$
^data-raw$
+^npm-shrinkwrap\.json$
+^\.Rprofile\.local$
+^inst/htmlwidgets/lib/.*/.*\.map$
+^inst/htmlwidgets/plugins/.*/.*\.map$
+^inst/htmlwidgets/lib/jquery/jquery.js$
+^inst/htmlwidgets/lib/leaflet/leaflet-src.js$
+^inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster.freezable-src.js$
+^inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster.layersupport-src.js$
+^inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster-src.js$
+^inst/htmlwidgets/lib/leaflet-measure/leaflet-measure.js$
+^inst/htmlwidgets/plugins/Proj4Leaflet/proj4.js$
diff --git a/DESCRIPTION b/DESCRIPTION
index 2c33f680a..72c079505 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -2,7 +2,7 @@ Package: leaflet
Type: Package
Title: Create Interactive Web Maps with the JavaScript 'Leaflet' Library
Version: 1.1.0.9000
-Date: 2017-02-17
+Date: 2017-11-05
Authors@R: c(
person("Joe", "Cheng", email = "joe@rstudio.com", role = c("aut", "cre")),
person("Bhaskar", "Karambelkar", role = c("aut")),
diff --git a/NAMESPACE b/NAMESPACE
index add9de3e2..a5932e938 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -18,6 +18,7 @@ S3method(pointData,data.frame)
S3method(pointData,default)
S3method(pointData,matrix)
S3method(pointData,sf)
+S3method(pointData,sfc_GEOMETRY)
S3method(pointData,sfc_POINT)
S3method(polygonData,Line)
S3method(polygonData,Lines)
@@ -106,6 +107,8 @@ export(expandLimits)
export(expandLimitsBbox)
export(filterNULL)
export(fitBounds)
+export(flyTo)
+export(flyToBounds)
export(getMapData)
export(groupOptions)
export(hideGroup)
diff --git a/NEWS b/NEWS
index 8d4a31947..d41b13371 100644
--- a/NEWS
+++ b/NEWS
@@ -10,12 +10,18 @@ leaflet 2.0
leaflet 1.1.1
--------------------------------------------------------------------------------
-* Add `groupOptions` parameter, currently the only option is letting you specify
+* Fix a bug where the default `addTiles()` would not work with .html files
+ served directly from the filesystem.
+
+* Add `groupOptions` function. Currently the only option is letting you specify
zoom levels at which a group should be visible.
* Fix bug with accessing columns in formulas when the data source is a Crosstalk
SharedData object wrapping a spatial data frame or sf object.
+* Fix strange wrapping behavior for legend, especially common for Chrome when
+ browser zoom level is not 100%.
+
* Fix incorrect opacity on NA entry in legend. (PR #425)
leaflet 1.1.0
diff --git a/R/layers.R b/R/layers.R
index 39e1af148..d9124db0d 100644
--- a/R/layers.R
+++ b/R/layers.R
@@ -127,6 +127,8 @@ hideGroup <- function(map, group) {
#'
#' @export
groupOptions <- function(map, group, zoomLevels = NULL) {
+ if(is.null(zoomLevels)) # Default to TRUE if nothing specified.
+ zoomLevels <- TRUE
invokeMethod(map, getMapData(map), 'setGroupOptions', group,
list(zoomLevels = zoomLevels)
)
@@ -145,7 +147,7 @@ groupOptions <- function(map, group, zoomLevels = NULL) {
#' \code{\link{popupOptions}}, \code{\link{markerOptions}},
#' \code{\link{pathOptions}}
#' @references The Leaflet API documentation:
-#' \url{http://leafletjs.com/reference.html}
+#' \url{http://leafletjs.com/reference-1.2.0.html}
#' @describeIn map-layers Add a tile layer to the map
#' @export
addTiles <- function(
@@ -209,6 +211,10 @@ epsg3857 <- "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y
#' the caller's responsibility to ensure that \code{x} is already projected,
#' and that \code{extent(x)} is expressed in WGS84 latitude/longitude
#' coordinates
+#' @param method the method used for computing values of the new, projected raster image.
+#' \code{"bilinear"} (the default) is appropriate for continuous data,
+#' \code{"ngb"} - nearest neighbor - is appropriate for categorical data.
+#' Ignored if \code{project = FALSE}. See \code{\link{projectRaster}} for details.
#' @param maxBytes the maximum number of bytes to allow for the projected image
#' (before base64 encoding); defaults to 4MB.
#'
@@ -231,12 +237,14 @@ addRasterImage <- function(
layerId = NULL,
group = NULL,
project = TRUE,
+ method = c("bilinear", "ngb"),
maxBytes = 4*1024*1024
) {
stopifnot(inherits(x, "RasterLayer"))
if (project) {
- projected <- projectRasterForLeaflet(x)
+ method <- match.arg(method, c("bilinear", "ngb"))
+ projected <- projectRasterForLeaflet(x, method)
} else {
projected <- x
}
@@ -266,8 +274,12 @@ addRasterImage <- function(
#' @rdname addRasterImage
#' @export
-projectRasterForLeaflet <- function(x) {
- raster::projectRaster(x, raster::projectExtent(x, crs = sp::CRS(epsg3857)))
+projectRasterForLeaflet <- function(x, method) {
+ raster::projectRaster(
+ x,
+ raster::projectExtent(x, crs = sp::CRS(epsg3857)),
+ method = method
+ )
}
#' @rdname remove
@@ -287,9 +299,9 @@ clearImages <- function(map) {
#' The rest of all possible options for map elements and layers that are not
#' listed in the layer functions.
#' @param
-#' minZoom,maxZoom,maxNativeZoom,tileSize,subdomains,errorTileUrl,tms,continuousWorld,noWrap,zoomOffset,zoomReverse,zIndex,unloadInvisibleTiles,updateWhenIdle,detectRetina,reuseTiles
+#' minZoom,maxZoom,maxNativeZoom,tileSize,subdomains,errorTileUrl,tms,noWrap,zoomOffset,zoomReverse,zIndex,unloadInvisibleTiles,updateWhenIdle,detectRetina
#' the tile layer options; see
-#' \url{http://leafletjs.com/reference.html#tilelayer}
+#' \url{http://leafletjs.com/reference-1.2.0.html#tilelayer}
#' @param ... extra options passed to underlying Javascript object constructor.
#' @describeIn map-options Options for tile layers
#' @export
@@ -301,7 +313,6 @@ tileOptions <- function(
subdomains = 'abc',
errorTileUrl = '',
tms = FALSE,
- continuousWorld = FALSE,
noWrap = FALSE,
zoomOffset = 0,
zoomReverse = FALSE,
@@ -310,19 +321,17 @@ tileOptions <- function(
unloadInvisibleTiles = NULL,
updateWhenIdle = NULL,
detectRetina = FALSE,
- reuseTiles = FALSE,
...
) {
- list(
+ filterNULL(list(
minZoom = minZoom, maxZoom = maxZoom, maxNativeZoom = maxNativeZoom,
tileSize = tileSize, subdomains = subdomains, errorTileUrl = errorTileUrl,
- tms = tms, continuousWorld = continuousWorld, noWrap = noWrap,
+ tms = tms, noWrap = noWrap,
zoomOffset = zoomOffset, zoomReverse = zoomReverse, opacity = opacity,
zIndex = zIndex, unloadInvisibleTiles = unloadInvisibleTiles,
updateWhenIdle = updateWhenIdle, detectRetina = detectRetina,
- reuseTiles = reuseTiles,
...
- )
+ ))
}
#' Remove elements from a map
@@ -370,6 +379,9 @@ addWMSTiles <- function(
map, baseUrl, layerId = NULL, group = NULL,
options = WMSTileOptions(), attribution = NULL, layers = ''
) {
+ if(layers == '') {
+ stop("layers is a required argument with comma-separated list of WMS layers to show")
+ }
options$attribution = attribution
options$layers = layers
invokeMethod(map, getMapData(map), 'addWMSTiles', baseUrl, layerId, group, options)
@@ -390,10 +402,10 @@ WMSTileOptions <- function(
styles = '', format = 'image/jpeg', transparent = FALSE, version = '1.1.1',
crs = NULL, ...
) {
- list(
+ filterNULL(list(
styles = styles, format = format, transparent = transparent,
version = version, crs = crs, ...
- )
+ ))
}
#' @param lng a numeric vector of longitudes, or a one-sided formula of the form
@@ -432,7 +444,7 @@ addPopups <- function(
#' @param className a CSS class name set on an element
#' @param
#' maxWidth,minWidth,maxHeight,autoPan,keepInView,closeButton,zoomAnimation,closeOnClick
-#' popup options; see \url{http://leafletjs.com/reference.html#popup}
+#' popup options; see \url{http://leafletjs.com/reference-1.2.0.html#popup-option}
#' @describeIn map-options Options for popups
#' @export
popupOptions <- function(
@@ -442,20 +454,16 @@ popupOptions <- function(
autoPan = TRUE,
keepInView = FALSE,
closeButton = TRUE,
- # offset = TODO,
- # autoPanPaddingTopLeft = TODO,
- # autoPanPaddingBottomRight = TODO,
- # autoPanPadding = TODO,
zoomAnimation = TRUE,
closeOnClick = NULL,
className = "",
...
) {
- list(
+ filterNULL(list(
maxWidth = maxWidth, minWidth = minWidth, maxHeight = maxHeight,
autoPan = autoPan, keepInView = keepInView, closeButton = closeButton,
zoomAnimation = zoomAnimation, closeOnClick = closeOnClick, className = className, ...
- )
+ ))
}
#' @rdname remove
@@ -496,8 +504,8 @@ safeLabel <- function(label, data) {
}
#' @param
-#' noHide,direction,offset,textsize,textOnly,style
-#' label options; see \url{http://leafletjs.com/reference-1.0.3.html#tooltip-option}
+#' noHide,direction,offset,textsize,textOnly,style,permanent
+#' label options; see \url{http://leafletjs.com/reference-1.2.0.html#tooltip-option}
#' @describeIn map-options Options for labels
#' @export
labelOptions <- function(
@@ -506,8 +514,7 @@ labelOptions <- function(
noHide = NULL,
permanent = FALSE,
className = '',
- direction = 'right',
- #pane = NULL,
+ direction = 'auto',
offset = c(0,0),
opacity = 1,
textsize = "10px",
@@ -516,17 +523,17 @@ labelOptions <- function(
zoomAnimation = TRUE,
...
) {
- # use old clickable if provided
+ # use old (Leaflet 0.7.x) clickable if provided
if(!is.null(clickable) && interactive != clickable) interactive <- clickable
# use old noHide if provided
if(!is.null(noHide) && permanent != noHide) permanent <- noHide
- list(
+ filterNULL(list(
interactive = interactive, permanent = permanent, direction = direction,
opacity = opacity, offset = offset,
textsize = textsize, textOnly = textOnly, style = style,
zoomAnimation = zoomAnimation, className = className, ...
- )
+ ))
}
#' @param icon the icon(s) for markers; an icon is represented by an R list of
@@ -631,9 +638,9 @@ markerClusterDependencies <- function() {
list(
htmltools::htmlDependency(
'leaflet-markercluster',
- '1.0.4',
+ '1.0.5',
system.file('htmlwidgets/plugins/Leaflet.markercluster', package = 'leaflet'),
- script = c('leaflet.markercluster.js', 'leaflet.markercluster.layersupport-src.js', 'leaflet.markercluster.freezable-src.js'),
+ script = c('leaflet.markercluster.js', 'leaflet.markercluster.freezable.js', 'leaflet.markercluster.layersupport.js'),
stylesheet = c('MarkerCluster.css', 'MarkerCluster.Default.css')
)
)
@@ -797,14 +804,16 @@ b64EncodePackedIcons <- function(packedIcons) {
packedIcons
}
-#' @param clickable whether the element emits mouse events
+#' @param interactive whether the element emits mouse events
+#' @param clickable DEPRECATED! Use the \code{interactive} option.
#' @param
#' draggable,keyboard,title,alt,zIndexOffset,opacity,riseOnHover,riseOffset
-#' marker options; see \url{http://leafletjs.com/reference.html#marker}
+#' marker options; see \url{http://leafletjs.com/reference-1.2.0.html#marker-option}
#' @describeIn map-options Options for markers
#' @export
markerOptions <- function(
- clickable = TRUE,
+ interactive = TRUE,
+ clickable = NULL,
draggable = FALSE,
keyboard = TRUE,
title = "",
@@ -815,11 +824,14 @@ markerOptions <- function(
riseOffset = 250,
...
) {
- list(
- clickable = clickable, draggable = draggable, keyboard = keyboard,
+ # use old (Leaflet 0.7.x) clickable if provided
+ if(!is.null(clickable) && interactive != clickable) interactive <- clickable
+
+ filterNULL(list(
+ interactive = interactive, draggable = draggable, keyboard = keyboard,
title = title, alt = alt, zIndexOffset = zIndexOffset, opacity = opacity,
riseOnHover = riseOnHover, riseOffset = riseOffset, ...
- )
+ ))
}
#' @param showCoverageOnHover when you mouse over a cluster it shows the bounds
@@ -829,7 +841,7 @@ markerOptions <- function(
#' spiderfy it so you can see all of its markers
#' @param removeOutsideVisibleBounds clusters and markers too far from the
#' viewport are removed from the map for performance
-#' @param spiderLegPolylineOptions Allows you to specify PolylineOptions (\url{http://leafletjs.com/reference.html#polyline-options}) to style spider legs. By default, they are { weight: 1.5, color: '#222', opacity: 0.5 }
+#' @param spiderLegPolylineOptions Allows you to specify PolylineOptions (\url{http://leafletjs.com/reference-1.2.0.html#polyline-option}) to style spider legs. By default, they are { weight: 1.5, color: '#222', opacity: 0.5 }
#' @param freezeAtZoom Allows you to freeze cluster expansion to a zoom level.
#' Can be a zoom level e.g. 10, 12 or 'max' or 'maxKeepSpiderify'
#' See \url{https://github.com/ghybs/Leaflet.MarkerCluster.Freezable#api-reference}
@@ -842,14 +854,14 @@ markerClusterOptions <- function(
freezeAtZoom = FALSE,
...
) {
- list(
+ filterNULL(list(
showCoverageOnHover = showCoverageOnHover,
zoomToBoundsOnClick = zoomToBoundsOnClick,
spiderfyOnMaxZoom = spiderfyOnMaxZoom,
removeOutsideVisibleBounds = removeOutsideVisibleBounds,
spiderLegPolylineOptions = spiderLegPolylineOptions,
freezeAtZoom = freezeAtZoom, ...
- )
+ ))
}
#' @param radius a numeric vector of radii for the circles; it can also be a
@@ -888,11 +900,11 @@ addCircleMarkers <- function(
clusterId = NULL,
data = getMapData(map)
) {
- options = c(options, list(
+ options = c(options, filterNULL(list(
stroke = stroke, color = color, weight = weight, opacity = opacity,
fill = fill, fillColor = fillColor, fillOpacity = fillOpacity,
dashArray = dashArray
- ))
+ )))
if (!is.null(clusterOptions))
map$dependencies = c(map$dependencies, markerClusterDependencies())
pts = derivePoints(data, lng, lat, missing(lng), missing(lat), "addCircleMarkers")
@@ -948,15 +960,18 @@ removeMarkerFromCluster <- function(map, layerId, clusterId) {
pathOptions <- function(
lineCap = NULL,
lineJoin = NULL,
- clickable = TRUE,
+ clickable = NULL,
+ interactive = TRUE,
pointerEvents = NULL,
className = "",
...
) {
- list(
- lineCap = lineCap, lineJoin = lineJoin, clickable = clickable,
+ # use old (Leaflet 0.7.x) clickable if provided
+ if(!is.null(clickable) && interactive != clickable) interactive <- clickable
+ filterNULL(list(
+ lineCap = lineCap, lineJoin = lineJoin, interactive = interactive ,
pointerEvents = pointerEvents, className = className, ...
- )
+ ))
}
#' Options to highlight shapes (polylines/polygons/circles/rectangles)
@@ -1010,11 +1025,11 @@ addCircles <- function(
highlightOptions = NULL,
data = getMapData(map)
) {
- options = c(options, list(
+ options = c(options, filterNULL(list(
stroke = stroke, color = color, weight = weight, opacity = opacity,
fill = fill, fillColor = fillColor, fillOpacity = fillOpacity,
dashArray = dashArray
- ))
+ )))
pts = derivePoints(data, lng, lat, missing(lng), missing(lat), "addCircles")
invokeMethod(map, data, 'addCircles', pts$lat, pts$lng, radius, layerId, group, options,
popup, popupOptions, safeLabel(label, data), labelOptions, highlightOptions,
@@ -1048,11 +1063,11 @@ addPolylines <- function(
highlightOptions = NULL,
data = getMapData(map)
) {
- options = c(options, list(
+ options = c(options, filterNULL(list(
stroke = stroke, color = color, weight = weight, opacity = opacity,
fill = fill, fillColor = fillColor, fillOpacity = fillOpacity,
dashArray = dashArray, smoothFactor = smoothFactor, noClip = noClip
- ))
+ )))
pgons = derivePolygons(data, lng, lat, missing(lng), missing(lat), "addPolylines")
invokeMethod(map, data, 'addPolylines', pgons, layerId, group, options,
popup, popupOptions, safeLabel(label, data), labelOptions, highlightOptions) %>%
@@ -1083,11 +1098,11 @@ addRectangles <- function(
highlightOptions = NULL,
data = getMapData(map)
) {
- options = c(options, list(
+ options = c(options, filterNULL(list(
stroke = stroke, color = color, weight = weight, opacity = opacity,
fill = fill, fillColor = fillColor, fillOpacity = fillOpacity,
dashArray = dashArray, smoothFactor = smoothFactor, noClip = noClip
- ))
+ )))
lng1 = resolveFormula(lng1, data)
lat1 = resolveFormula(lat1, data)
lng2 = resolveFormula(lng2, data)
@@ -1122,11 +1137,11 @@ addPolygons <- function(
highlightOptions = NULL,
data = getMapData(map)
) {
- options = c(options, list(
+ options = c(options, filterNULL(list(
stroke = stroke, color = color, weight = weight, opacity = opacity,
fill = fill, fillColor = fillColor, fillOpacity = fillOpacity,
dashArray = dashArray, smoothFactor = smoothFactor, noClip = noClip
- ))
+ )))
pgons = derivePolygons(data, lng, lat, missing(lng), missing(lat), "addPolygons")
invokeMethod(map, data, 'addPolygons', pgons, layerId, group, options, popup, popupOptions, safeLabel(label, data), labelOptions, highlightOptions) %>%
expandLimitsBbox(pgons)
@@ -1160,11 +1175,11 @@ addGeoJSON <- function(map, geojson, layerId = NULL, group = NULL,
noClip = FALSE,
options = pathOptions()
) {
- options = c(options, list(
+ options = c(options, filterNULL(list(
stroke = stroke, color = color, weight = weight, opacity = opacity,
fill = fill, fillColor = fillColor, fillOpacity = fillOpacity,
dashArray = dashArray, smoothFactor = smoothFactor, noClip = noClip
- ))
+ )))
invokeMethod(map, getMapData(map), 'addGeoJSON', geojson, layerId, group, options)
}
@@ -1183,7 +1198,7 @@ clearGeoJSON <- function(map) {
#' Add UI controls to switch layers on and off
#'
#' Uses Leaflet's built-in
-#' \href{http://leafletjs.com/reference.html#control-layers}{layers control}
+#' \href{http://leafletjs.com/reference-1.2.0.html#control-layers}{layers control}
#' feature to allow users to choose one of several base layers, and to choose
#' any number of overlay layers to view.
#'
@@ -1230,7 +1245,7 @@ addLayersControl <- function(map,
#' @param ... other options for \code{layersControlOptions()}
#' @export
layersControlOptions <- function(collapsed = TRUE, autoZIndex = TRUE, ...) {
- list(collapsed = collapsed, autoZIndex = autoZIndex, ...)
+ filterNULL(list(collapsed = collapsed, autoZIndex = autoZIndex, ...))
}
#' @rdname addLayersControl
diff --git a/R/leaflet.R b/R/leaflet.R
index 427f81c29..2fa5eb342 100644
--- a/R/leaflet.R
+++ b/R/leaflet.R
@@ -21,12 +21,15 @@
#' @param height the height of the map
#' @param padding the padding of the map
#' @param options the map options
+#' @param elementId Use an explicit element ID for the widget
+#' (rather than an automatically generated one).
#' @return A HTML widget object, on which we can add graphics layers using
#' \code{\%>\%} (see examples).
#' @example inst/examples/leaflet.R
#' @export
leaflet <- function(data = NULL, width = NULL, height = NULL,
- padding = 0, options = leafletOptions()) {
+ padding = 0, options = leafletOptions(),
+ elementId = NULL) {
# Validate the CRS if specified
if(!is.null(options[['crs']]) &&
@@ -61,7 +64,8 @@ leaflet <- function(data = NULL, width = NULL, height = NULL,
})
}
widget
- }
+ },
+ elementId = elementId
)
if (crosstalk::is.SharedData(data)) {
@@ -117,7 +121,7 @@ mapOptions <- function(map, zoomToLimits = c("always", "first", "never")) {
#' @param worldCopyJump With this option enabled, the map tracks when you pan to another "copy" of the world and seamlessly jumps to the original one so that all overlays like markers and vector layers are still visible.
#' @param ... other options.
#' @describeIn leaflet Options for map creation
-#' @seealso \url{http://leafletjs.com/reference.html#map-options} for details.
+#' @seealso \url{http://leafletjs.com/reference-1.2.0.html#map-option} for details.
#' @export
leafletOptions <- function(
minZoom = NULL,
@@ -142,10 +146,10 @@ crsClasses <- list('L.CRS.EPSG3857', 'L.CRS.EPSG4326', 'L.CRS.EPSG3395',
#' creates a custom CRS
#' Refer to \url{https://kartena.github.io/Proj4Leaflet/api/} for details.
#' @param crsClass One of L.CRS.EPSG3857, L.CRS.EPSG4326, L.CRS.EPSG3395,
-#' L.CRS.Simple, L.Proj.CRS, L.Proj.CRS.TMS
+#' L.CRS.Simple, L.Proj.CRS
#' @param code CRS identifier
#' @param proj4def Proj4 string
-#' @param projectedBounds Only when crsClass = 'L.Proj.CRS.TMS'
+#' @param projectedBounds DEPRECATED! Use the bounds argument.
#' @param origin Origin in projected coordinates, if set overrides transformation option.
#' @param transformation to use when transforming projected coordinates into pixel coordinates
#' @param scales Scale factors (pixels per projection unit, for example pixels/meter)
@@ -155,8 +159,7 @@ crsClasses <- list('L.CRS.EPSG3857', 'L.CRS.EPSG4326', 'L.CRS.EPSG3395',
#' @param bounds Bounds of the CRS, in projected coordinates; if defined,
#' Proj4Leaflet will use this in the getSize method, otherwise
#' defaulting to Leaflet's default CRS size
-#' @param tileSize Tile size, in pixels, to use in this CRS (Default 256)
-#' Only needed when crsClass = 'L.Proj.CRS.TMS'
+#' @param tileSize DEPRECATED! Specify the tilesize in the \code{\link{tileOptions}()} argument.
#' @describeIn leaflet class to create a custom CRS
#' @export
leafletCRS <- function(
@@ -171,18 +174,32 @@ leafletCRS <- function(
bounds = NULL,
tileSize = NULL
) {
+
+ # Deprecated since Leaflet JS 1.x
+ if(!missing(projectedBounds)) {
+ warning("projectedBounds argument is deprecated and has no effect, use the bounds argument.")
+ }
+ if(!missing(tileSize)) {
+ warning("tileSize argument is deprecated and has no effect, use the tileOptions() function to pass the tileSize argument to the addTiles() function")
+ }
+ if(crsClass == 'L.Proj.CRS.TMS') {
+ warning("L.Proj.CRS.TMS is deprecated and will behave exactly like L.Proj.CRS.")
+ }
+
if(!crsClass %in% crsClasses) {
stop(sprintf("crsClass argument must be one of %s",
paste0(crsClasses, collapse = ', ')))
-
}
+
+
+
if(crsClass %in% c('L.Proj.CRS', 'L.Proj.CRS.TMS') &&
!is.null(scales) && !is.null(resolutions)) {
- stop(sprintf("Either input scales or resolutions"))
+ stop(sprintf("Either specify scales or resolutions"))
}
if(crsClass %in% c('L.Proj.CRS', 'L.Proj.CRS.TMS') &&
is.null(scales) && is.null(resolutions)) {
- stop(sprintf("Input either scales or resolutions, not both"))
+ stop(sprintf("Specify either scales or resolutions, not both"))
}
structure(
list(
diff --git a/R/methods.R b/R/methods.R
index ac2e43169..fd721157b 100644
--- a/R/methods.R
+++ b/R/methods.R
@@ -6,8 +6,8 @@
#' @param lat The latitude of the map center
#' @param zoom the zoom level
#' @param options a list of zoom/pan options (see
-#' \url{http://leafletjs.com/reference.html#map-zoompanoptions})
-#' @references \url{http://leafletjs.com/reference.html#map-set-methods}
+#' \url{http://leafletjs.com/reference-1.2.0.html#zoom/pan-options})
+#' @references \url{http://leafletjs.com/reference-1.2.0.html#map-methods-for-modifying-map-state}
#' @return The modified map widget.
#' @describeIn map-methods Set the view of the map (center and zoom level)
#' @export
@@ -33,11 +33,31 @@ setView <- function(map, lng, lat, zoom, options = list()) {
)
}
+#' @describeIn map-methods Flys to a given location/zoom-level using smooth pan-zoom.
+#' @export
+flyTo <- function(map, lng, lat, zoom, options = list()) {
+ view = evalFormula(list(c(lat, lng), zoom, options))
+
+ dispatch(map,
+ "flyTo",
+ leaflet = {
+ map$x$flyTo = view
+ map$x$fitBounds = NULL
+ map
+ },
+ leaflet_proxy = {
+ invokeRemote(map, "flyTo", view)
+ map
+ }
+ )
+}
+
+
#' @describeIn map-methods Set the bounds of a map
#' @param lng1,lat1,lng2,lat2 the coordinates of the map bounds
#' @export
-fitBounds <- function(map, lng1, lat1, lng2, lat2) {
- bounds = evalFormula(list(lat1, lng1, lat2, lng2), getMapData(map))
+fitBounds <- function(map, lng1, lat1, lng2, lat2, options = list()) {
+ bounds = evalFormula(list(lat1, lng1, lat2, lng2, options), getMapData(map))
dispatch(map,
"fitBounds",
@@ -53,6 +73,25 @@ fitBounds <- function(map, lng1, lat1, lng2, lat2) {
)
}
+#' @describeIn map-methods Flys to given bound using smooth pan/zoom.
+#' @export
+flyToBounds <- function(map, lng1, lat1, lng2, lat2, options = list()) {
+ bounds = evalFormula(list(lat1, lng1, lat2, lng2, options), getMapData(map))
+
+ dispatch(map,
+ "flyToBounds",
+ leaflet = {
+ map$x$flyToBounds = bounds
+ map$x$setView = NULL
+ map
+ },
+ leaflet_proxy = {
+ invokeRemote(map, "flyToBounds", bounds)
+ map
+ }
+ )
+}
+
#' @describeIn map-methods Restricts the map view to the given bounds
#' @export
setMaxBounds <- function(map, lng1, lat1, lng2, lat2) {
diff --git a/R/normalize-sf.R b/R/normalize-sf.R
index 84f16938a..6f8853396 100644
--- a/R/normalize-sf.R
+++ b/R/normalize-sf.R
@@ -9,12 +9,16 @@ metaData.sf <- function(obj) {
#' @export
pointData.sf <- function(obj) {
- geometry <- obj[[attr(obj, "sf_column")]]
- pointData(geometry)
+ pointData(sf::st_geometry(obj))
}
#' @export
pointData.sfc_POINT <- function(obj) {
+ if (length(obj) == 0) {
+ # If a sfc_GEOMETRY is empty, just return nothing.
+ return(data.frame(lng = numeric(0), lat = numeric(0)))
+ }
+
check_crs(obj)
structure(
@@ -44,6 +48,21 @@ pointData.POINT <- function(obj) {
)
}
+#' @export
+pointData.sfc_GEOMETRY <- function(obj) {
+ if (length(obj) == 0) {
+ # If a sfc_GEOMETRY is empty, just return nothing.
+ data.frame(lng = numeric(0), lat = numeric(0))
+ } else if (all(vapply(obj, inherits, logical(1), "POINT"))) {
+ # If it's all POINT objects, then treat it as sfc_POINT.
+ pointData.sfc_POINT(obj)
+ } else {
+ # Otherwise, we don't know what to do. Let pointData.default throw an
+ # error.
+ NextMethod("pointData")
+ }
+}
+
# polygonData -------------------------------------------------------------
#' @export
diff --git a/R/normalize.R b/R/normalize.R
index 9c3211556..28868dd6b 100644
--- a/R/normalize.R
+++ b/R/normalize.R
@@ -92,7 +92,7 @@ derivePolygons <- function(data, lng = NULL, lat = NULL,
lng = resolveFormula(lng, data)
lat = resolveFormula(lat, data)
- df <- validateCoords(lng, lat, funcName)
+ df <- validateCoords(lng, lat, funcName, mode = "polygon")
polygonData(cbind(df$lng, df$lat))
}
diff --git a/R/plugin-graticule.R b/R/plugin-graticule.R
index 17420da58..651364615 100644
--- a/R/plugin-graticule.R
+++ b/R/plugin-graticule.R
@@ -15,7 +15,7 @@ leafletGraticuleDependencies <- function() {
#' @param map a map widget object
#' @param interval The spacing in map units between horizontal and vertical lines.
#' @param sphere boolean. Default FALSE
-#' @param style path options for the generated lines. See \url{http://leafletjs.com/reference.html#path-options}
+#' @param style path options for the generated lines. See \url{http://leafletjs.com/reference-1.2.0.html#path-option}
#' @param layerId the layer id
#' @param group the name of the group this layer belongs to.
#' @param options the path options for the graticule layer
diff --git a/R/plugin-measure.R b/R/plugin-measure.R
index 2c3880cd5..32ea7a0a6 100644
--- a/R/plugin-measure.R
+++ b/R/plugin-measure.R
@@ -2,7 +2,7 @@ leafletMeasureDependencies <- function() {
list(
htmltools::htmlDependency(
"leaflet-measure",
- "2.1.5",
+ "2.1.7",
system.file("htmlwidgets/lib/leaflet-measure", package = "leaflet"),
script = "leaflet-measure.min.js",
stylesheet = "leaflet-measure.css"
@@ -13,7 +13,7 @@ leafletMeasureDependencies <- function() {
#' Add a measure control to the map.
#'
#' @param map a map widget object
-#' @param position standard \href{http://leafletjs.com/reference.html#control-positions}{Leaflet control position options}.
+#' @param position standard \href{http://leafletjs.com/reference-1.2.0.html#control-positions}{Leaflet control position options}.
#' @param primaryLengthUnit,secondaryLengthUnit units used to display length
#' results. secondaryLengthUnit is optional.
#' Valid values are \code{"feet"}, \code{"meters"}, \code{"miles"}, and \code{"kilometers"}.
@@ -28,7 +28,7 @@ leafletMeasureDependencies <- function() {
#' Value should be a color represented as a hexadecimal string.
#' @param popupOptions \code{list} of options applied to the popup
#' of the resulting measure feature.
-#' Properties may be any \href{http://leafletjs.com/reference.html#popup-options}{standard Leaflet popup options}.
+#' Properties may be any \href{http://leafletjs.com/reference-1.2.0.html#popup-option}{standard Leaflet popup options}.
#' @param captureZIndex Z-index of the marker used to capture measure clicks.
#' Set this value higher than the z-index of all other map layers to
#' disable click events on other layers while a measurement is active.
diff --git a/R/plugin-minimap.R b/R/plugin-minimap.R
index cafd55a02..9f693abd4 100644
--- a/R/plugin-minimap.R
+++ b/R/plugin-minimap.R
@@ -45,10 +45,10 @@ leafletMiniMapDependencies <- function() {
#' Especially useful when 'zoomLevelFixed' is set.
#' @param minimized Sets whether the minimap should start in a minimized position.
#' @param aimingRectOptions Sets the style of the aiming rectangle by passing in
-#' a Path.Options (\url{http://leafletjs.com/reference.html#path-options}) object.
+#' a Path.Options (\url{http://leafletjs.com/reference-1.2.0.html#path-options}) object.
#' (Clickable will always be overridden and set to false.)
#' @param shadowRectOptions Sets the style of the aiming shadow rectangle by passing in
-#' a Path.Options (\url{http://leafletjs.com/reference.html#path-options}) object.
+#' a Path.Options (\url{http://leafletjs.com/reference-1.2.0.html#path-option}) object.
#' (Clickable will always be overridden and set to false.)
#' @param strings Overrides the default strings allowing for translation.
#' @param tiles URL for tiles or one of the pre-defined providers.
diff --git a/R/plugin-providers.R b/R/plugin-providers.R
index 27d20e815..c25812422 100644
--- a/R/plugin-providers.R
+++ b/R/plugin-providers.R
@@ -2,7 +2,7 @@ leafletProviderDependencies <- function() {
list(
htmltools::htmlDependency(
"leaflet-providers",
- "1.0.27",
+ "1.1.17",
system.file("htmlwidgets/lib/leaflet-providers", package = "leaflet"),
script = "leaflet-providers.js"
),
@@ -48,23 +48,21 @@ addProviderTiles <- function(
}
#' @param
-#' errorTileUrl,noWrap,opacity,zIndex,unloadInvisibleTiles,updateWhenIdle,detectRetina,reuseTiles
+#' errorTileUrl,noWrap,opacity,zIndex,updateWhenIdle,detectRetina
#' the tile layer options; see
-#' \url{http://leafletjs.com/reference.html#tilelayer}
+#' \url{http://leafletjs.com/reference-1.2.0.html#tilelayer}
#' @param ... named parameters to add to the options
#' @rdname addProviderTiles
#' @export
providerTileOptions <- function(errorTileUrl = '', noWrap = FALSE,
- opacity = NULL, zIndex = NULL, unloadInvisibleTiles = NULL,
- updateWhenIdle = NULL, detectRetina = FALSE, reuseTiles = FALSE, ...
+ opacity = NULL, zIndex = NULL,
+ updateWhenIdle = NULL, detectRetina = FALSE, ...
) {
- opts <- list(errorTileUrl = errorTileUrl, noWrap = noWrap,
- zIndex = zIndex, unloadInvisibleTiles = unloadInvisibleTiles,
+ opts <- filterNULL(list(
+ errorTileUrl = errorTileUrl, noWrap = noWrap,
+ opacity = opacity, zIndex = zIndex,
updateWhenIdle = updateWhenIdle, detectRetina = detectRetina,
- reuseTiles = reuseTiles, ...)
- # Don't include opacity=NULL--it overrides the provider's default opacity
- if (!is.null(opacity))
- opts$opacity <- opacity
+ ...))
opts
}
@@ -83,5 +81,3 @@ providerTileOptions <- function(errorTileUrl = '', noWrap = FALSE,
#' @format A list of lists (JSON)
#' @source \url{https://github.com/leaflet-extras/leaflet-providers/blob/master/leaflet-providers.js}
"providers.details"
-
-
diff --git a/R/scalebar.R b/R/scalebar.R
index 9be441c0a..98ff3618e 100644
--- a/R/scalebar.R
+++ b/R/scalebar.R
@@ -1,7 +1,7 @@
#' Add or remove a scale bar
#'
#' Uses Leaflet's built-in
-#' \href{http://leafletjs.com/reference.html#control-scale}{scale bar}
+#' \href{http://leafletjs.com/reference-1.2.0.html#control-scale}{scale bar}
#' feature to add a scale bar.
#'
#' @param map the map to add the scale bar to
diff --git a/R/selection.R b/R/selection.R
index 1cfa88947..bef2cf201 100644
--- a/R/selection.R
+++ b/R/selection.R
@@ -2,7 +2,7 @@ locationFilter2Dependencies <- function() {
list(
htmltools::htmlDependency(
"leaflet-locationfilter2",
- "0.1.0",
+ "0.1.1",
system.file("htmlwidgets/plugins/leaflet-locationfilter", package = "leaflet"),
script = c("locationfilter.js", "locationfilter-bindings.js"),
stylesheet = c("locationfilter.css")
diff --git a/R/utils.R b/R/utils.R
index 43a0021d1..e578b5641 100644
--- a/R/utils.R
+++ b/R/utils.R
@@ -263,8 +263,15 @@ makeListFun <- function(list) {
#' @param lat vector with latitude values
#' @param funcName Name of calling function
#' @param warn A boolean. Whether to generate a warning message if there are rows with missing/invalid data
+#' @param mode if \code{"point"} then warn about any \code{NA} lng/lat values;
+#' if \code{"polygon"} then \code{NA} values are expected to be used as
+#' polygon delimiters
#' @export
-validateCoords <- function(lng, lat, funcName, warn=T) {
+validateCoords <- function(lng, lat, funcName, warn=TRUE,
+ mode = c("point", "polygon")) {
+
+ mode <- match.arg(mode)
+
if (is.null(lng) && is.null(lat)) {
stop(funcName, " requires non-NULL longitude/latitude values")
} else if (is.null(lng)) {
@@ -280,13 +287,19 @@ validateCoords <- function(lng, lat, funcName, warn=T) {
} else if (!is.numeric(lat)) {
stop(funcName, " requires numeric latitude values")
}
- complete <- ifelse(
- is.na(lat) | is.null(lat) | is.na(lng) | is.null(lng) |
- !is.numeric(lat) | !is.numeric(lng),
- FALSE, TRUE)
- if(any(!complete)) {
- warning(sprintf("Data contains %s rows with either missing or invalid lat/lon values and will be ignored",sum(!complete)))
+ if (mode == "point") {
+ incomplete <- is.na(lat) | is.na(lng)
+ if(any(incomplete)) {
+ warning(sprintf("Data contains %s rows with either missing or invalid lat/lon values and will be ignored",sum(incomplete)))
+ }
+ } else if (mode == "polygon") {
+ incomplete <- is.na(lat) != is.na(lng)
+ if(any(incomplete)) {
+ warning(sprintf("Data contains %s rows with either missing or invalid lat/lon values and will be ignored",sum(incomplete)))
+ }
+ lng <- lng[!incomplete]
+ lat <- lat[!incomplete]
}
data.frame(lng=lng,lat=lat)
diff --git a/README.md b/README.md
index 1c69f69f5..a378cb7a8 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# An R Interface to Leaflet Maps
-[](https://travis-ci.org/rstudio/leaflet)
+[](https://travis-ci.org/rstudio/leaflet)
[Leaflet](http://leafletjs.com) is an open-source JavaScript library for
interactive maps. This R package makes it easy to create Leaflet maps from R.
diff --git a/data-raw/providerNames.R b/data-raw/providerNames.R
index bf015cfb5..89ac32fe7 100644
--- a/data-raw/providerNames.R
+++ b/data-raw/providerNames.R
@@ -1,6 +1,8 @@
# The JSON was extracted and fixed from ...
# https://github.com/leaflet-extras/leaflet-providers/blob/master/leaflet-providers.js
+library(magrittr)
+
providers.details <- jsonlite::fromJSON(
'./inst/htmlwidgets/lib/leaflet-providers/providers.json')
diff --git a/data/providers.details.rda b/data/providers.details.rda
index 7e6cf5960..66d6d59d2 100644
Binary files a/data/providers.details.rda and b/data/providers.details.rda differ
diff --git a/data/providers.rda b/data/providers.rda
index 0d750ff2f..0f953ae90 100644
Binary files a/data/providers.rda and b/data/providers.rda differ
diff --git a/inst/errors/errors.Rmd b/inst/errors/errors.Rmd
deleted file mode 100644
index 11425f86d..000000000
--- a/inst/errors/errors.Rmd
+++ /dev/null
@@ -1,56 +0,0 @@
-# Errors
-
-### ? leaflet
-
-
-```{r}
-m %>% addMarkers(rand_lng(), rand_lat())
-# html/css/js errors
-# imagesmarker-icon-2x.png Failed to load resource: the server responded with a status of 403 (Forbidden)
-# imagesmarker-shadow.png Failed to load resource: the server responded with a status of 403 (Forbidden)
-```
-
-error was pre-existing and not caused by 1.0.3
-fixed but not solved [commit](https://github.com/timelyportfolio/leaflet/commit/4b841f02c399a206c84642a42e5eb189498f9b65)
-
-
-### controls
-
-leaflet-measure and layersControl do not remove
-
-not an `v1.0.3` issue but fixed [commit](https://github.com/timelyportfolio/leaflet/commit/c6762e313f268954d8c19225177a991129c20a98) and [commit](https://github.com/timelyportfolio/leaflet/commit/55334c10536f6bc0b7250139e64e262f2cb48c51). However, none of controls use `ControlStore` mechanism, so would be nice to resolve this on a grander scale.
-
-
-### labels/tooltips
-
-https://github.com/Leaflet/Leaflet.label#upgrade-path-to-ltooltip
-
-leaflet-label now in main leaflet as L.tooltip. How do we handle changed options in `labelOptions`?. Do we just translate `clickable` to `interactive` and `clickable` to `interactive` in R so old examples still work?
-
-**NOTE: starting with Leaflet 1.0, `L.Label` is added to Leaflet core as `L.Tooltip` and this plugin is deprecrated.**
-
-### Upgrade path to L.Tooltip
-
-- `bindLabel`, `openLabel` and so should be replaced by `bindTooltip`, `openTooltip`, etc.
-- option `clickable` is now named `interactive`
-- option `noHide` is now named `permanent`
-- default `offset` is now [6, -6]
-- default `direction` is now `auto`
-- default `opacity` is now `0.9`
-- the CSS has been fully refactored
-
-- Bonus: L.Tooltip also works for paths: polygons, polylines, etc.
-- Bonus: new directions are supported: `top`, `bottom`, `center`
-- Bonus: new option `sticky` will make the label follow the mouse instead of being displayed at the feature center
-
-
-* removed leaflet-label source and in yaml in [commit]()
-
-
-### tileLayer.canvas no longer available
-
-```
-library(mapview)
-
-leaflet() %>% addRasterImage(poppendorf[[1]])
-```
diff --git a/inst/examples/awesomeMarkers.R b/inst/examples/awesomeMarkers.R
index 7e076b77a..cb72a23b2 100644
--- a/inst/examples/awesomeMarkers.R
+++ b/inst/examples/awesomeMarkers.R
@@ -72,7 +72,7 @@ popIcons <- awesomeIconList(
blue = makeAwesomeIcon(icon='user', library='glyphicon', markerColor = 'blue'),
red = makeAwesomeIcon(icon='users', library='fa', markerColor = 'red'))
-leaflet(cities) %>% addTiles() %>%
+leaflet(cities) %>% addProviderTiles(providers$CartoDB.DarkMatter) %>%
addAwesomeMarkers(lng = ~Long, lat = ~Lat,
label = ~City,
labelOptions = rep(labelOptions(noHide = T),nrow(cities)),
diff --git a/inst/examples/crosstalk.R b/inst/examples/crosstalk.R
deleted file mode 100644
index d27822929..000000000
--- a/inst/examples/crosstalk.R
+++ /dev/null
@@ -1,34 +0,0 @@
-# devtools::install_github("rstudio/crosstalk")
-# devtools::install_github("rstudio/leaflet")
-
-library(crosstalk)
-library(leaflet)
-library(htmlwidgets)
-
-rand_lng = function(n = 10) rnorm(n, -93.65, .01)
-rand_lat = function(n = 10) rnorm(n, 42.0285, .01)
-
-pts <- SharedData$new(
- data.frame(
- lng = rand_lng(),
- lat = rand_lat()
- ),
- group = "grp1"
-)
-
-
-lf <- leaflet(pts) %>%
- addTiles() %>%
- addMarkers()
-
-
-onRender(
- lf,
-"
-function(el,x) {
- debugger;
- var sl = new crosstalk.SelectionHandle('grp1');
- sl.on('change', function(val){console.log(val);})
-}
-"
-)
diff --git a/inst/examples/crosstalk_shiny.R b/inst/examples/crosstalk_shiny.R
deleted file mode 100644
index c8035f281..000000000
--- a/inst/examples/crosstalk_shiny.R
+++ /dev/null
@@ -1,65 +0,0 @@
-# devtools::install_github("rstudio/crosstalk")
-# devtools::install_github("rstudio/leaflet")
-
-library(crosstalk)
-library(leaflet)
-library(shiny)
-library(dplyr)
-
-rand_lng = function(n = 10) rnorm(n, -93.65, .01)
-rand_lat = function(n = 10) rnorm(n, 42.0285, .01)
-
-pts <- SharedData$new(
- data.frame(
- id = 1:10,
- lng = rand_lng(),
- lat = rand_lat()
- ),
- key = ~id,
- group = "grp1"
-)
-
-
-ui <- fluidPage(
- fluidRow(
- column(2, filter_select(id="filterselect", label="Points", sharedData=pts, group=~id)),
- column(6, leafletOutput("leaflet1"))
- ),
- h4("Selected points"),
- verbatimTextOutput("selectedpoints")
-)
-
-server <- function(input, output, session) {
-
- pts <- SharedData$new(
- data.frame(
- id = 1:10,
- lng = rand_lng(),
- lat = rand_lat()
- ),
- key = ~id,
- group = "grp1"
- )
-
-
- lf <- leaflet(pts) %>%
- addTiles() %>%
- addMarkers()
-
- not_rendered <- TRUE
-
- output$leaflet1 <- renderLeaflet({
- if(req(not_rendered,cancelOutput=TRUE)) {
- not_rendered <- FALSE
- lf
- }
- })
-
- output$selectedpoints <- renderPrint({
- df <- pts$data(withSelection = TRUE)
- cat(nrow(df), "observation(s) selected\n\n")
- str(dplyr::glimpse(df))
- })
-}
-
-shinyApp(ui, server)
diff --git a/inst/examples/draw_shiny_deleted.R b/inst/examples/draw_shiny_deleted.R
deleted file mode 100644
index 099b43f5e..000000000
--- a/inst/examples/draw_shiny_deleted.R
+++ /dev/null
@@ -1,30 +0,0 @@
-library(leaflet)
-library(leaflet.extras)
-library(shiny)
-
-#using examples from ?leaflet
-rand_lng = function(n = 10) rnorm(n, -93.65, .01)
-rand_lat = function(n = 10) rnorm(n, 42.0285, .01)
-m = leaflet() %>%
- addTiles() %>%
- addPolygons(rand_lng(4), rand_lat(4), group = 'foo') %>%
- addPolygons(rand_lng(4), rand_lat(4), group = 'foo') %>%
- addDrawToolbar(targetGroup = "foo", editOptions = editToolbarOptions())
-
-# do this in GlobalEnv only for example purposes
-deleted <- list()
-ui <- leafletOutput("leafmap")
-server <- function(input, output, session) {
- output$leafmap <- renderLeaflet({m})
-
- observeEvent(input$leafmap_draw_deleted_features,{
- str(input$leafmap_draw_deleted_features, max.level=2)
- deleted <<- c(
- deleted,
- input$leafmap_draw_deleted_features
- )
- })
-}
-shinyApp(ui, server)
-
-str(deleted, max.level=2)
diff --git a/inst/examples/experiment_split.R b/inst/examples/experiment_split.R
deleted file mode 100644
index 0915dca2a..000000000
--- a/inst/examples/experiment_split.R
+++ /dev/null
@@ -1,113 +0,0 @@
-library(htmltools)
-library(leaflet)
-library(pipeR)
-
-lf <- leaflet(width="100%") %>% addTiles()
-
-css <- "
-html, body {
- height: 100%;
-}
-body {
-padding: 8px;
-background-color: #F6F6F6;
-box-sizing: border-box;
-}
-.split {
--webkit-box-sizing: border-box;
--moz-box-sizing: border-box;
-box-sizing: border-box;
-overflow-y: auto;
-overflow-x: hidden;
-}
-.content {
-border: 1px solid #C0C0C0;
-box-shadow: inset 0 1px 2px #e4e4e4;
-background-color: #fff;
-}
-.gutter {
-background-color: transparent;
-background-repeat: no-repeat;
-background-position: 50%;
-}
-.gutter.gutter-horizontal {
-cursor: col-resize;
-background-image: url('https://cdn.rawgit.com/nathancahill/Split.js/877632e1/grips/vertical.png');
-}
-.gutter.gutter-vertical {
-cursor: row-resize;
-background-image: url('https://cdn.rawgit.com/nathancahill/Split.js/877632e1/grips/horizontal.png');
-}
-.split.split-horizontal, .gutter.gutter-horizontal {
-height: 100%;
-float: left;
-}
-"
-
-tagList(
- tags$link(rel="stylesheet", href="https://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.3/normalize.css"),
- tags$script(src="https://cdnjs.cloudflare.com/ajax/libs/split.js/1.2.0/split.min.js"),
- tags$style(css),
- tags$div(
- style = "height:410px;",
- tags$div(
- id = "map1",
- class = "split split-horizontal",
- tags$div(class="split content", lf)
- ),
- tags$div(
- id = "map2",
- class = "split split horizontal",
- tags$div(class="split content", lf)
- )
- ),
- tags$script('
-Split(["#map1", "#map2"], {
- gutterSize: 8,
- cursor: "col-resize",
- onDragEnd: function(evt){
- $(".html-widget",$(event.target).parent().parent()).each(function(hw){
- HTMLWidgets.find("#" + this.id).resize()
- })
- }
-})
- ')
-) %>>%
- browsable()
-
-
-
-library(svglite)
-svg1 <- htmlSVG({contour(volcano)}, standalone=FALSE)
-
-tagList(
- tags$link(rel="stylesheet", href="https://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.3/normalize.css"),
- tags$script(src="https://cdnjs.cloudflare.com/ajax/libs/split.js/1.2.0/split.min.js"),
- tags$style(css),
- tags$div(
- style = "height:410px;",
- tags$div(
- id = "map1",
- class = "split split-horizontal",
- tags$div(class="split content", lf)
- ),
- tags$div(
- id = "map2",
- class = "split split horizontal",
- tags$div(class="split content", svg1)
- )
- ),
- tags$script('
-Split(["#map1", "#map2"], {
- gutterSize: 8,
- cursor: "col-resize",
- onDragEnd: function(evt){
- $(".html-widget",$(event.target).parent().parent()).each(function(hw){
- HTMLWidgets.find("#" + this.id).resize()
- })
- }
-})
- ')
- ) %>>%
- browsable()
-
diff --git a/inst/examples/gadget_draw.R b/inst/examples/gadget_draw.R
deleted file mode 100644
index 32c140d06..000000000
--- a/inst/examples/gadget_draw.R
+++ /dev/null
@@ -1,45 +0,0 @@
-# start toward a Shiny gadget for Leaflet and Leaflet.Draw
-# still missing many features but hopefully serves
-# as proof of concept
-
-#' Leaflet Draw Shiny Gadget
-#'
-#' @param lf leaflet map currently with \code{addDrawToolbar} already
-#' added.
-#' @param width,height valid \code{CSS} size for the gadget
-
-leafdraw_gadget <- function(lf = NULL, height = NULL, width = NULL) {
- # modeled after chemdoodle gadget
- # https://github.com/zachcp/chemdoodle/blob/master/R/chemdoodle_sketcher_gadgets.R
- stopifnot(requireNamespace("miniUI"), requireNamespace("shiny"))
- ui <- miniUI::miniPage(
- miniUI::miniContentPanel(lf, height=NULL, width=NULL),
-
- miniUI::gadgetTitleBar("Draw Something", right = miniUI::miniTitleBarButton("done", "Done", primary = TRUE))
- )
-
- server <- function(input, output, session) {
- shiny::observeEvent(input$done, { shiny::stopApp(input$undefined_draw_new_feature) })
- shiny::observeEvent(input$cancel, { shiny::stopApp (NULL) })
- }
-
- shiny::runGadget(
- ui,
- server,
- viewer = shiny::dialogViewer("View and Edit Data"),
- stopOnCancel = FALSE
- )
-}
-
-
-# example use
-library(leaflet)
-library(leaflet.extras)
-library(mapview)
-
-lf <- mapview(breweries91)@map %>%
- addTiles() %>%
- addDrawToolbar()
-
-drawn <- leafdraw_gadget(lf)
-drawn
diff --git a/inst/examples/gadget_draw2.R b/inst/examples/gadget_draw2.R
deleted file mode 100644
index c266a5efb..000000000
--- a/inst/examples/gadget_draw2.R
+++ /dev/null
@@ -1,95 +0,0 @@
-# start toward a Shiny gadget for Leaflet and Leaflet.Draw
-# still missing many features but hopefully serves
-# as proof of concept
-
-#' Leaflet Draw Shiny Gadget
-#'
-#' @param lf leaflet map currently with \code{addDrawToolbar} already
-#' added.
-#' @param width,height valid \code{CSS} size for the gadget
-
-drawonme <- function(lf = NULL, height = NULL, width = NULL) {
- # modeled after chemdoodle gadget
- # https://github.com/zachcp/chemdoodle/blob/master/R/chemdoodle_sketcher_gadgets.R
- stopifnot(requireNamespace("miniUI"), requireNamespace("shiny"))
- ui <- miniUI::miniPage(
- miniUI::miniContentPanel(lf, height=NULL, width=NULL),
- miniUI::gadgetTitleBar("Draw Something", right = miniUI::miniTitleBarButton("done", "Done", primary = TRUE))
- )
-
- server <- function(input, output, session) {
- drawn <- list()
- edited <- list()
-
- shiny::observeEvent(input$undefined_draw_new_feature, {
- # we can clean this up
- drawn <<- c(drawn, list(input$undefined_draw_new_feature))
- })
-
- shiny::observeEvent(input$undefined_draw_edited_features, {
- edited <<- input$undefined_draw_edited_features
- # find the edited features and update drawn
- # start by getting the leaflet ids to do the match
- ids <- unlist(lapply(drawn, function(x){x$properties$`_leaflet_id`}))
- # now modify drawn to match edited
- lapply(edited$features, function(x){
- loc <- match(x$properties$`_leaflet_id`, ids)
- drawn[loc] <<- list(x)
- })
- })
-
- shiny::observeEvent(input$done, { shiny::stopApp(drawn) })
- shiny::observeEvent(input$cancel, { shiny::stopApp (NULL) })
- }
-
- shiny::runGadget(
- ui,
- server,
- viewer = shiny::dialogViewer("Draw and Edit"),
- stopOnCancel = FALSE
- )
-}
-
-
-# example use
-library(leaflet)
-library(leaflet.extras)
-library(mapview)
-
-lf <- mapview(breweries91)@map %>%
- addTiles() %>%
- addDrawToolbar(editOptions = editToolbarOptions())
-
-drawn <- drawonme(lf)
-drawn
-
-Reduce(
- function(x,y) {
- x %>% addGeoJSON(y)
- },
- drawn,
- init = lf
-)
-
-library(lawn)
-l_pts <- lawn_featurecollection(
- as.list(unname(apply(breweries91@coords,MARGIN=1,lawn_point)))
-)
-
-l_poly <- lawn_featurecollection(
- list(lawn_polygon(drawn[[1]]$geometry$coordinates))
-)
-
-l_in <- lawn_within(l_pts, l_poly)
-l_out <- lawn_featurecollection(Filter(
- function(pt) {
- !lawn_inside(pt, lawn_polygon(drawn[[1]]$geometry$coordinates))
- },
- as.list(unname(apply(breweries91@coords,MARGIN=1,lawn_point)))
-))
-
-view(l_in) %>%
- addGeoJSON(drawn[[1]])
-
-view(l_out) %>%
- addGeoJSON(drawn[[1]])
diff --git a/inst/examples/labels.R b/inst/examples/labels.R
index 17704e6a8..9f0f32859 100644
--- a/inst/examples/labels.R
+++ b/inst/examples/labels.R
@@ -35,7 +35,7 @@ leaflet() %>% addTiles() %>%
lng=-118.456554, lat=34.079979, radius = 5,
label='On the Top',
labelOptions = labelOptions(noHide = T, direction = 'top',
- offset=c(0,-45))
+ offset=c(0,-15))
)%>%
addCircleMarkers(
lng=-118.456554, lat=34.076279, radius = 5,
diff --git a/inst/examples/mapedit_attribute_poc.R b/inst/examples/mapedit_attribute_poc.R
deleted file mode 100644
index a89453dbe..000000000
--- a/inst/examples/mapedit_attribute_poc.R
+++ /dev/null
@@ -1,42 +0,0 @@
-library(mapview)
-library(listviewer)
-library(htmltools)
-library(shiny)
-
-lf <- mapview(breweries91)@map
-
-lf_popup <- htmlwidgets::onRender(
- lf,
-'
-function(el,x) {
- var map = this;
- map.on("popupopen", function(x){
- editpopup(x);
- })
-}
-'
-)
-
-tagList(
- fluidPage(
- fluidRow(
- column(7,lf_popup),
- column(4,listviewer::jsonedit(width="100%", elementId="popup-editor"))
- )
- ),
- tags$script(
-'
-function editpopup(popup) {
-debugger;
- var editor = HTMLWidgets.find("#popup-editor").editor;
- var cells = $("td",popup.popup._contentNode);
- var info = {};
-
- cells.each(function(i,d){if(i%2===0){info[$(d).text()]=$(cells[i+1]).html()}})
-
- editor.set(info);
-}
-'
- )
-) %>%
- browsable()
diff --git a/inst/examples/polarProjections.R b/inst/examples/proj4Leaflet-PolarProjections.R
similarity index 98%
rename from inst/examples/polarProjections.R
rename to inst/examples/proj4Leaflet-PolarProjections.R
index 37aa51120..befb2f1bf 100644
--- a/inst/examples/polarProjections.R
+++ b/inst/examples/proj4Leaflet-PolarProjections.R
@@ -73,7 +73,7 @@ polarmaps <- purrr::map2(crses, tileURLtemplates,
addTiles(urlTemplate = tileURLTemplate,
attribution = "Map © ArcticConnect. Data © OpenStreetMap contributors",
options = tileOptions(subdomains = "abc", noWrap = TRUE,
- continuousWorld = FALSE))
+ continuousWorld = FALSE, detectRetina = TRUE))
})
#' #### EPSG:3571
diff --git a/inst/examples/proj4Leaflet-TMS.R b/inst/examples/proj4Leaflet-TMS.R
new file mode 100644
index 000000000..ff0a1a937
--- /dev/null
+++ b/inst/examples/proj4Leaflet-TMS.R
@@ -0,0 +1,84 @@
+library(mapview) # for the popupTables
+library(sp)
+
+#' ## Leaflet Example of using EPSG:28892 Projection
+#'
+
+proj4def.4326 <- "+proj=longlat +datum=WGS84 +no_defs"
+proj4def.28992 <- '+proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 +ellps=bessel +units=m +towgs84=565.2369,50.0087,465.658,-0.406857330322398,0.350732676542563,-1.8703473836068,4.0812 +no_defs'
+
+data(meuse)
+coordinates(meuse) <- ~x+y
+proj4string(meuse) <- proj4def.28992
+meuse.4326 <- spTransform(meuse, proj4def.4326)
+
+
+#' ### Map + Markers in the Default Spherical Mercator
+#' Just to verify that everything is correct in 4326
+leaflet() %>% addTiles() %>%
+ addCircleMarkers(data=meuse.4326)
+
+
+#' ### Now in EPSG:28992
+
+minZoom = 0
+maxZoom = 13
+resolutions <- c(3440.640, 1720.320, 860.160, 430.080, 215.040, 107.520, 53.760, 26.880, 13.440, 6.720, 3.360, 1.680, 0.840, 0.420)
+bounds <- list(c(-285401.92, 22598.08), c(595401.9199999999, 903401.9199999999))
+origin <- c(-285401.92, 22598.08)
+
+crs.epsg28992 <- leafletCRS(crsClass = 'L.Proj.CRS', code = 'EPSG:28992',
+ proj4def = proj4def.28992,
+ resolutions = resolutions,
+ bounds = bounds,
+ origin = origin)
+
+leaflet(options = leafletOptions(
+ crs = crs.epsg28992, minZoom = 0, maxZoom = 13)) %>%
+ addTiles('http://geodata.nationaalgeoregister.nl/tms/1.0.0/brtachtergrondkaart/{z}/{x}/{y}.png',
+ options = tileOptions(tms=TRUE,
+ errorTileUrl = 'http://www.webmapper.net/theme/img/missing-tile.png'),
+ attribution = 'Map data: Kadaster') %>%
+ addCircleMarkers(data = meuse.4326, popup = popupTable(meuse))
+
+
+#' ## Korean TMS Provider
+
+#' ### Map + Markers in the Default Spherical Mercator
+#' Just to verify that everything is correct in 4326
+leaflet() %>%
+ addTiles() %>%
+ addMarkers(126.615810, 35.925937, label='Gunsan Airpoirt',
+ labelOptions = labelOptions(noHide = TRUE))
+
+#' ### Now with EPSG 5181 Projection
+
+crs.epsg5181 <- leafletCRS(
+ crsClass = 'L.Proj.CRS',
+ code = 'EPSG:5181',
+ proj4def = '+proj=tmerc +lat_0=38 +lon_0=127 +k=1 +x_0=200000 +y_0=500000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs',
+ resolutions = c(2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0.5, 0.25),
+ origin = c(-30000, -60000),
+ bounds = list(c(-30000, -60000), c(494288, 464288))
+ )
+
+map <- leaflet(options = leafletOptions(
+ crs = crs.epsg5181,
+ continuousWorld = TRUE,
+ worldCopyJump = FALSE
+))
+
+map %>%
+ addTiles(
+ urlTemplate = 'http://i{s}.maps.daum-img.net/map/image/G03/i/1.20/L{z}/{y}/{x}.png',
+ attribution = 'ⓒ Daum',
+ options = tileOptions(
+ maxZoom = 14,
+ minZoom = 0,
+ zoomReverse = TRUE,
+ subdomains = '0123',
+ continuousWorld = TRUE,
+ tms = TRUE
+ )) %>%
+ addMarkers(126.615810, 35.925937, label='Gunsan Airpoirt',
+ labelOptions = labelOptions(noHide = TRUE))
diff --git a/inst/examples/proj4Leaflet.R b/inst/examples/proj4Leaflet.R
index 7c8150870..f7b3ed653 100644
--- a/inst/examples/proj4Leaflet.R
+++ b/inst/examples/proj4Leaflet.R
@@ -6,30 +6,32 @@ library(leaflet)
#' Default SPherical Mercator Projection specified explicitly
leaflet(
options =
- leafletOptions(crs=leafletCRS(crsClass='L.CRS.EPSG3857'))) %>% addTiles()
+ leafletOptions(crs=leafletCRS(crsClass='L.CRS.EPSG3857'))) %>%
+ addTiles()
#'
Gothenberg, Sweeden in default projection
leaflet() %>%
- addTiles() %>% setView(11.965, 57.704, 16)
+ addTiles() %>%
+ setView(11.965, 57.704, 16)
#'
Gothenberg, Sweeden in local projection
leaflet(
options =
leafletOptions(
- worldCopyJump = FALSE,
crs=leafletCRS(
crsClass="L.Proj.CRS",
code='EPSG:3006',
proj4def='+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs',
resolutions = c(
8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0.5 ),
- origin =c(0, 0))
+ origin =c(0, 0)
+ )
)) %>%
addTiles(
urlTemplate = 'http://api.geosition.com/tile/osm-bright-3006/{z}/{x}/{y}.png',
attribution = 'Map data © OpenStreetMap contributors, Imagery © 2013 Kartena',
- options = tileOptions(minZoom=0,maxZoom=14,continuousWorld = TRUE)) %>%
+ options = tileOptions(minZoom=0,maxZoom=14)) %>%
setView(11.965, 57.704, 13)
#'
diff --git a/inst/examples/proj4leaflet_with_tms.R b/inst/examples/proj4leaflet_with_tms.R
deleted file mode 100644
index 990b7aac3..000000000
--- a/inst/examples/proj4leaflet_with_tms.R
+++ /dev/null
@@ -1,102 +0,0 @@
-library(mapview) # for the popupTables
-library(sp)
-
-#' ## Example of using EPSG:28892 Projection
-
-#' Helper function to query proj4 strings for an EPSG code.
-#' Not fool proof but works for correct codes.
-getEPSG <- function(epsgCode){
- res <- httr::GET(sprintf(
- "http://epsg.io/?q=%s&format=json",epsgCode))
- if(res$status_code==200) {
- return(httr::content(res))
- } else {
- warning(sprintf(
- "Error querying EPSG code %s, Server returned %d:%s",
- epsgCode, res$status_code, httr::content(res)))
- return(NULL)
- }
-}
-
-getProj4String <- function(epsgCode) {
- res <- getEPSG(epsgCode)
- if(!is.null(res) && length(res$results)>=1) {
- return(res$results[[1]]$proj4)
- } else {
- return(NULL)
- }
-}
-
-proj4def.28992 <- getProj4String('28992')
-proj4def.28992
-proj4def.4326 <- getProj4String('4326')
-proj4def.4326
-
-data(meuse)
-coordinates(meuse) <- ~x+y
-proj4string(meuse) <- proj4def.28992
-meuse.4326 <- spTransform(meuse, proj4def.4326)
-
-
-#' ### Map + Markers in Spherical Mercator
-#' Just to verify that everything is correct in 4326
-leaflet() %>% addTiles() %>%
- addCircleMarkers(data=meuse.4326)
-
-
-#' ## Now in EPSG:28992
-
-minZoom = 0
-maxZoom = 13
-
-# lenght of resultions vector needs to correspond to maxZoom+1-minZoom
-# I use the 0.42 multiplyer from the resolutions arg found at http://jsfiddle.net/_Tom_/ueRa8/
-resolutions <- 0.42*(2^(maxZoom:minZoom))
-
-crs.28992 <- leafletCRS(
- crsClass = "L.Proj.CRS",
- code = 'EPSG:28992',
- proj4def = proj4def.28992,
- resolutions = resolutions)
-
-#' ### Just the markers
-#' No need to call setView, leaflet (R package)
-#' will auto determine the best initial view based on data.
-leaflet(options = leafletOptions(crs = crs.28992,
- minZoom = minZoom,
- maxZoom = maxZoom)) %>%
- addCircleMarkers(data = meuse.4326, popup = popupTable(meuse))
-
-#' ### Markers + Tiles
-#' All this is adapted from http://jsfiddle.net/_Tom_/ueRa8/
-#'
We will use TMS http://geodata.nationaalgeoregister.nl
-
-crs.28992.forTiles <- leafletCRS(
- crsClass = "L.Proj.CRS.TMS",
- code = 'EPSG:28992',
- proj4def = proj4def.28992,
- resolutions = resolutions,
- projectedBounds = c(-285401.92, 22598.08, 595401.9199999999, 903401.9199999999))
-
-#' This works but there's a problem when going from Zoom level 9 to 10
-#' I've started at zoom level 9, if you zoom out it works perfectly
-#' If you zoom in then there's a problem from zoom level 10 onwards
-#' but the problem is with the Tile Map Server (TMS) + Proj4 and not the markers.
-#' You can verify that with the bottom map which is only tiles
-leaflet(options = leafletOptions(crs = crs.28992.forTiles,
- minZoom = minZoom,
- maxZoom = maxZoom)) %>%
- addCircleMarkers(data = meuse.4326, popup = popupTable(meuse)) %>%
- setView(5.734745, 50.964112, zoom = 9) %>%
- addTiles('http://geodata.nationaalgeoregister.nl/tms/1.0.0/brtachtergrondkaart/{z}/{x}/{y}.png', options = tileOptions(tms=TRUE)) %>%
- htmlwidgets::onRender("function(el,t){ var myMap=this; debugger; }")
-
-
-#' ### Problem with zooming
-#' You can see the problem when zooming from level 9 to 10 below.
-leaflet(options = leafletOptions(crs = crs.28992.forTiles,
- minZoom = minZoom,
- maxZoom = maxZoom)) %>%
- setView(5.734745, 50.964112, zoom = 9) %>%
- addTiles('http://geodata.nationaalgeoregister.nl/tms/1.0.0/brtachtergrondkaart/{z}/{x}/{y}.png', options = tileOptions(tms=TRUE)) %>%
- htmlwidgets::onRender("function(el,t){ var myMap=this; debugger; }")
diff --git a/inst/examples/sf_leafletdraw_intersect.R b/inst/examples/sf_leafletdraw_intersect.R
deleted file mode 100644
index 37047825a..000000000
--- a/inst/examples/sf_leafletdraw_intersect.R
+++ /dev/null
@@ -1,52 +0,0 @@
-# devtools::install_github("rstudio/leaflet")
-
-library(leaflet)
-library(leaflet.extras)
-library(lawn)
-library(geojsonio)
-library(sf)
-library(htmlwidgets)
-
-pts <- gr_point(n=10, c(-93.64, 42.0185 , -93.66, 42.0385))
-
-#convert to simple features
-pts_sf <- st_as_sf(geojson_sp(
- geojson_list(lawn:::convert(pts))
-))
-
-#make a leaflet to experiment
-lf <- pts_sf %>%
- leaflet() %>%
- addCircles() %>%
- addDrawToolbar(editOptions=editToolbarOptions()) %>%
- addTiles()
-
-library(shiny)
-#options(shiny.trace=TRUE)
-ui <- lf
-server <- function(input, output, session) {
- observeEvent(input$undefined_draw_new_feature,{
- print(input$undefined_draw_new_feature)
- edit_shape <<- input$undefined_draw_new_feature
- })
-}
-shinyApp(ui, server)
-
-
-# we should have saved edit_shape in GlobalEnv
-# if anything was drawn with Leaflet.Draw
-# let's assume it was a polygon
-
-shape_sf <- st_polygon(
- list(
- matrix(unlist(edit_shape$geometry$coordinates[[1]]),ncol=2,byrow=TRUE)
- )
-)
-shape_sfc <- st_sfc(shape_sf,crs=st_crs(pts_sf))
-st_intersection(pts_sf, shape_sfc)
-# map to see result (sort of invert)
-leaflet() %>%
- addCircles(data=st_intersection(pts_sf, shape_sfc)) %>%
- addCircles(data=st_difference(pts_sf, shape_sfc), color = "red") %>%
- addPolygons(data=shape_sfc) %>%
- addTiles()
diff --git a/inst/htmlwidgets/leaflet.js b/inst/htmlwidgets/leaflet.js
index 3a23c0c64..0aa9333cc 100644
--- a/inst/htmlwidgets/leaflet.js
+++ b/inst/htmlwidgets/leaflet.js
@@ -184,7 +184,10 @@ function getCRS(crsOptions) {
if (crsOptions.options && crsOptions.options.transformation) {
crsOptions.options.transformation = _leaflet2.default.Transformation(crsOptions.options.transformation[0], crsOptions.options.transformation[1], crsOptions.options.transformation[2], crsOptions.options.transformation[3]);
}
- crs = new _proj4leaflet2.default.CRS.TMS(crsOptions.code, crsOptions.proj4def, crsOptions.projectedBounds, crsOptions.options);
+ // L.Proj.CRS.TMS is deprecated as of Leaflet 1.x, fall back to L.Proj.CRS
+ //crs = new Proj4Leaflet.CRS.TMS(crsOptions.code, crsOptions.proj4def,
+ //crsOptions.projectedBounds, crsOptions.options);
+ crs = new _proj4leaflet2.default.CRS(crsOptions.code, crsOptions.proj4def, crsOptions.options);
break;
}
return crs;
@@ -633,6 +636,14 @@ _htmlwidgets2.default.widget({
explicitView = true;
methods.fitBounds.apply(map, data.fitBounds);
}
+ if (data.flyTo) {
+ explicitView = true;
+ map.flyTo.apply(map, data.flyTo);
+ }
+ if (data.flyToBounds) {
+ explicitView = true;
+ methods.flyToBounds.apply(map, data.flyToBounds);
+ }
if (data.options.center) {
explicitView = true;
}
@@ -1109,7 +1120,7 @@ var LayerManager = function () {
if (layerInfo.ctGroup) {
var ctGroup = this._byCrosstalkGroup[layerInfo.ctGroup];
var layersForKey = ctGroup[layerInfo.ctKey];
- var idx = layersForKey ? layersForKey.indexOf(stamp) : -1;
+ var idx = layersForKey ? layersForKey.indexOf(+stamp) : -1;
if (idx >= 0) {
if (layersForKey.length === 1) {
delete ctGroup[layerInfo.ctKey];
@@ -1208,8 +1219,16 @@ methods.setView = function (center, zoom, options) {
this.setView(center, zoom, options);
};
-methods.fitBounds = function (lat1, lng1, lat2, lng2) {
- this.fitBounds([[lat1, lng1], [lat2, lng2]]);
+methods.fitBounds = function (lat1, lng1, lat2, lng2, options) {
+ this.fitBounds([[lat1, lng1], [lat2, lng2]], options);
+};
+
+methods.flyTo = function (center, zoom, options) {
+ this.flyTo(center, zoom, options);
+};
+
+methods.flyToBounds = function (lat1, lng1, lat2, lng2, options) {
+ this.flyToBounds([[lat1, lng1], [lat2, lng2]], options);
};
methods.setMaxBounds = function (lat1, lng1, lat2, lng2) {
@@ -1337,6 +1356,7 @@ function addMarkers(map, df, group, clusterOptions, clusterId, markerFunc) {
marker.on("click", mouseHandler(this.id, thisId, thisGroup, "marker_click", extraInfo), this);
marker.on("mouseover", mouseHandler(this.id, thisId, thisGroup, "marker_mouseover", extraInfo), this);
marker.on("mouseout", mouseHandler(this.id, thisId, thisGroup, "marker_mouseout", extraInfo), this);
+ marker.on("dragend", mouseHandler(this.id, thisId, thisGroup, "marker_dragend", extraInfo), this);
}).call(_this3);
}
};
@@ -1856,12 +1876,12 @@ methods.addLegend = function (options) {
height: totalHeight + vMargin * 2 + "px"
});
- if (options.na_color) {
+ if (options.na_color && _jquery2.default.inArray(options.na_label, labels) < 0) {
(0, _jquery2.default)(div).append("
"),a=a.replace(/\n/g,"
"),"
"+a+"
"},e.nl2br=function(a){return a.replace(/(\r\n|\n|\r)/g,"<%= i18n.__(\'startCreating\') %>
\n \n \n<%= i18n.__(\'lastPoint\') %>
\n<%= model.lastCoord.dms.y %> / <%= model.lastCoord.dms.x %>
\n<%= humanize.numberFormat(model.lastCoord.dd.y, 6) %> / <%= humanize.numberFormat(model.lastCoord.dd.x, 6) %>
\n<%= i18n.__(\'pathDistance\') %> <%= model.lengthDisplay %>
\n<%= i18n.__(\'area\') %> <%= model.areaDisplay %>
\n<%= model.lastCoord.dms.y %> / <%= model.lastCoord.dms.x %>
\n<%= humanize.numberFormat(model.lastCoord.dd.y, 6) %> / <%= humanize.numberFormat(model.lastCoord.dd.x, 6) %>
\n'),n=c.template('<%= model.lengthDisplay %>
\n'),o=c.template('<%= model.areaDisplay %>
\n<%= model.lengthDisplay %> <%= i18n.__(\'perimeter\') %>
\n'),p=new(a("i18n-2"))({devMode:!1,locales:{ca:a("./i18n/ca"),cn:a("./i18n/cn"),da:a("./i18n/da"),de:a("./i18n/de"),de_CH:a("./i18n/de_CH"),en:a("./i18n/en"),en_UK:a("./i18n/en_UK"),es:a("./i18n/es"),fa:a("./i18n/fa"),fil_PH:a("./i18n/fil_PH"),fr:a("./i18n/fr"),it:a("./i18n/it"),nl:a("./i18n/nl"),pl:a("./i18n/pl"),pt_BR:a("./i18n/pt_BR"),pt_PT:a("./i18n/pt_PT"),ru:a("./i18n/ru"),tr:a("./i18n/tr")}});d.Control.Measure=d.Control.extend({_className:"leaflet-control-measure",options:{units:{},position:"topright",primaryLengthUnit:"feet",secondaryLengthUnit:"miles",primaryAreaUnit:"acres",activeColor:"#ABE67E",completedColor:"#C8F2BE",captureZIndex:1e4,popupOptions:{className:"leaflet-measure-resultpopup",autoPanPadding:[10,10]}},initialize:function(a){d.setOptions(this,a),this.options.units=d.extend({},f,this.options.units),this._symbols=new j(c.pick(this.options,"activeColor","completedColor")),p.setLocale(this.options.localization)},onAdd:function(a){return this._map=a,this._latlngs=[],this._initLayout(),a.on("click",this._collapse,this),this._layer=d.layerGroup().addTo(a),this._container},onRemove:function(a){a.off("click",this._collapse,this),a.removeLayer(this._layer)},_initLayout:function(){var a,b,c,e,f=this._className,g=this._container=d.DomUtil.create("div",f);g.innerHTML=k({model:{className:f},i18n:p}),g.setAttribute("aria-haspopup",!0),d.Browser.touch?d.DomEvent.on(g,"click",d.DomEvent.stopPropagation):(d.DomEvent.disableClickPropagation(g),d.DomEvent.disableScrollPropagation(g)),a=this.$toggle=i(".js-toggle",g),this.$interaction=i(".js-interaction",g),b=i(".js-start",g),c=i(".js-cancel",g),e=i(".js-finish",g),this.$startPrompt=i(".js-startprompt",g),this.$measuringPrompt=i(".js-measuringprompt",g),this.$startHelp=i(".js-starthelp",g),this.$results=i(".js-results",g),this.$measureTasks=i(".js-measuretasks",g),this._collapse(),this._updateMeasureNotStarted(),d.Browser.android||(d.DomEvent.on(g,"mouseenter",this._expand,this),d.DomEvent.on(g,"mouseleave",this._collapse,this)),d.DomEvent.on(a,"click",d.DomEvent.stop),d.Browser.touch?d.DomEvent.on(a,"click",this._expand,this):d.DomEvent.on(a,"focus",this._expand,this),d.DomEvent.on(b,"click",d.DomEvent.stop),d.DomEvent.on(b,"click",this._startMeasure,this),d.DomEvent.on(c,"click",d.DomEvent.stop),d.DomEvent.on(c,"click",this._finishMeasure,this),d.DomEvent.on(e,"click",d.DomEvent.stop),d.DomEvent.on(e,"click",this._handleMeasureDoubleClick,this)},_expand:function(){h.hide(this.$toggle),h.show(this.$interaction)},_collapse:function(){this._locked||(h.hide(this.$interaction),h.show(this.$toggle))},_updateMeasureNotStarted:function(){h.hide(this.$startHelp),h.hide(this.$results),h.hide(this.$measureTasks),h.hide(this.$measuringPrompt),h.show(this.$startPrompt)},_updateMeasureStartedNoPoints:function(){h.hide(this.$results),h.show(this.$startHelp),h.show(this.$measureTasks),h.hide(this.$startPrompt),h.show(this.$measuringPrompt)},_updateMeasureStartedWithPoints:function(){h.hide(this.$startHelp),h.show(this.$results),h.show(this.$measureTasks),h.hide(this.$startPrompt),h.show(this.$measuringPrompt)},_startMeasure:function(){this._locked=!0,this._measureVertexes=d.featureGroup().addTo(this._layer),this._captureMarker=d.marker(this._map.getCenter(),{ -clickable:!0,zIndexOffset:this.options.captureZIndex,opacity:0}).addTo(this._layer),this._setCaptureMarkerIcon(),this._captureMarker.on("mouseout",this._handleMapMouseOut,this).on("dblclick",this._handleMeasureDoubleClick,this).on("click",this._handleMeasureClick,this),this._map.on("mousemove",this._handleMeasureMove,this).on("mouseout",this._handleMapMouseOut,this).on("move",this._centerCaptureMarker,this).on("resize",this._setCaptureMarkerIcon,this),d.DomEvent.on(this._container,"mouseenter",this._handleMapMouseOut,this),this._updateMeasureStartedNoPoints(),this._map.fire("measurestart",null,!1)},_finishMeasure:function(){var a=c.extend({},this._resultsModel,{points:this._latlngs});this._locked=!1,d.DomEvent.off(this._container,"mouseover",this._handleMapMouseOut,this),this._clearMeasure(),this._captureMarker.off("mouseout",this._handleMapMouseOut,this).off("dblclick",this._handleMeasureDoubleClick,this).off("click",this._handleMeasureClick,this),this._map.off("mousemove",this._handleMeasureMove,this).off("mouseout",this._handleMapMouseOut,this).off("move",this._centerCaptureMarker,this).off("resize",this._setCaptureMarkerIcon,this),this._layer.removeLayer(this._measureVertexes).removeLayer(this._captureMarker),this._measureVertexes=null,this._updateMeasureNotStarted(),this._collapse(),this._map.fire("measurefinish",a,!1)},_clearMeasure:function(){this._latlngs=[],this._resultsModel=null,this._measureVertexes.clearLayers(),this._measureDrag&&this._layer.removeLayer(this._measureDrag),this._measureArea&&this._layer.removeLayer(this._measureArea),this._measureBoundary&&this._layer.removeLayer(this._measureBoundary),this._measureDrag=null,this._measureArea=null,this._measureBoundary=null},_centerCaptureMarker:function(){this._captureMarker.setLatLng(this._map.getCenter())},_setCaptureMarkerIcon:function(){this._captureMarker.setIcon(d.divIcon({iconSize:this._map.getSize().multiplyBy(2)}))},_getMeasurementDisplayStrings:function(a){function b(a,b,e,f,g){var h;return b&&d[b]?(h=c(a,d[b],f,g),e&&d[e]&&(h=h+" ("+c(a,d[e],f,g)+")")):h=c(a,null,f,g),h}function c(a,b,c,d){return b&&b.factor&&b.display?e.numberFormat(a*b.factor,b.decimals||0,c||p.__("decPoint"),d||p.__("thousandsSep"))+" "+p.__([b.display])||b.display:e.numberFormat(a,0,c||p.__("decPoint"),d||p.__("thousandsSep"))}var d=this.options.units;return{lengthDisplay:b(a.length,this.options.primaryLengthUnit,this.options.secondaryLengthUnit,this.options.decPoint,this.options.thousandsSep),areaDisplay:b(a.area,this.options.primaryAreaUnit,this.options.secondaryAreaUnit,this.options.decPoint,this.options.thousandsSep)}},_updateResults:function(){var a=g.measure(this._latlngs),b=this._resultsModel=c.extend({},a,this._getMeasurementDisplayStrings(a),{pointCount:this._latlngs.length});this.$results.innerHTML=l({model:b,humanize:e,i18n:p})},_handleMeasureMove:function(a){this._measureDrag?this._measureDrag.setLatLng(a.latlng):this._measureDrag=d.circleMarker(a.latlng,this._symbols.getSymbol("measureDrag")).addTo(this._layer),this._measureDrag.bringToFront()},_handleMeasureDoubleClick:function(){var a,b,f,h,j,k,l=this._latlngs;this._finishMeasure(),l.length&&(l.length>2&&l.push(c.first(l)),a=g.measure(l),1===l.length?(b=d.circleMarker(l[0],this._symbols.getSymbol("resultPoint")),h=m({model:a,humanize:e,i18n:p})):2===l.length?(b=d.polyline(l,this._symbols.getSymbol("resultLine")),h=n({model:c.extend({},a,this._getMeasurementDisplayStrings(a)),humanize:e,i18n:p})):(b=d.polygon(l,this._symbols.getSymbol("resultArea")),h=o({model:c.extend({},a,this._getMeasurementDisplayStrings(a)),humanize:e,i18n:p})),f=d.DomUtil.create("div",""),f.innerHTML=h,j=i(".js-zoomto",f),j&&(d.DomEvent.on(j,"click",d.DomEvent.stop),d.DomEvent.on(j,"click",function(){this._map.fitBounds(b.getBounds(),{padding:[20,20],maxZoom:17})},this)),k=i(".js-deletemarkup",f),k&&(d.DomEvent.on(k,"click",d.DomEvent.stop),d.DomEvent.on(k,"click",function(){this._layer.removeLayer(b)},this)),b.addTo(this._layer),b.bindPopup(f,this.options.popupOptions),b.openPopup(b.getBounds().getCenter()))},_handleMeasureClick:function(a){var b=this._map.mouseEventToLatLng(a.originalEvent),d=c.last(this._latlngs),e=this._symbols.getSymbol("measureVertex");d&&b.equals(d)||(this._latlngs.push(b),this._addMeasureArea(this._latlngs),this._addMeasureBoundary(this._latlngs),this._measureVertexes.eachLayer(function(a){a.setStyle(e),a._path.setAttribute("class",e.className)}),this._addNewVertex(b),this._measureBoundary&&this._measureBoundary.bringToFront(),this._measureVertexes.bringToFront()),this._updateResults(),this._updateMeasureStartedWithPoints()},_handleMapMouseOut:function(){this._measureDrag&&(this._layer.removeLayer(this._measureDrag),this._measureDrag=null)},_addNewVertex:function(a){d.circleMarker(a,this._symbols.getSymbol("measureVertexActive")).addTo(this._measureVertexes)},_addMeasureArea:function(a){return a.length<3?void(this._measureArea&&(this._layer.removeLayer(this._measureArea),this._measureArea=null)):void(this._measureArea?this._measureArea.setLatLngs(a):this._measureArea=d.polygon(a,this._symbols.getSymbol("measureArea")).addTo(this._layer))},_addMeasureBoundary:function(a){return a.length<2?void(this._measureBoundary&&(this._layer.removeLayer(this._measureBoundary),this._measureBoundary=null)):void(this._measureBoundary?this._measureBoundary.setLatLngs(a):this._measureBoundary=d.polyline(a,this._symbols.getSymbol("measureBoundary")).addTo(this._layer))}}),d.Map.mergeOptions({measureControl:!1}),d.Map.addInitHook(function(){this.options.measureControl&&(this.measureControl=(new d.Control.Measure).addTo(this))}),d.control.measure=function(a){return new d.Control.Measure(a)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./calc":23,"./dom":24,"./i18n/ca":25,"./i18n/cn":26,"./i18n/da":27,"./i18n/de":28,"./i18n/de_CH":29,"./i18n/en":30,"./i18n/en_UK":31,"./i18n/es":32,"./i18n/fa":33,"./i18n/fil_PH":34,"./i18n/fr":35,"./i18n/it":36,"./i18n/nl":37,"./i18n/pl":38,"./i18n/pt_BR":39,"./i18n/pt_PT":40,"./i18n/ru":41,"./i18n/tr":42,"./mapsymbology":44,"./units":45,humanize:16,"i18n-2":18,underscore:22}],44:[function(a,b,c){var d=a("underscore"),e=a("color"),f=function(a){this.setOptions(a)};f.DEFAULTS={activeColor:"#ABE67E",completedColor:"#C8F2BE"},d.extend(f.prototype,{setOptions:function(a){return this._options=d.extend({},f.DEFAULTS,this._options,a),this},getSymbol:function(a){var b={measureDrag:{clickable:!1,radius:4,color:this._options.activeColor,weight:2,opacity:.7,fillColor:this._options.activeColor,fillOpacity:.5,className:"layer-measuredrag"},measureArea:{clickable:!1,stroke:!1,fillColor:this._options.activeColor,fillOpacity:.2,className:"layer-measurearea"},measureBoundary:{clickable:!1,color:this._options.activeColor,weight:2,opacity:.9,fill:!1,className:"layer-measureboundary"},measureVertex:{clickable:!1,radius:4,color:this._options.activeColor,weight:2,opacity:1,fillColor:this._options.activeColor,fillOpacity:.7,className:"layer-measurevertex"},measureVertexActive:{clickable:!1,radius:4,color:this._options.activeColor,weight:2,opacity:1,fillColor:e(this._options.activeColor).darken(.15),fillOpacity:.7,className:"layer-measurevertex active"},resultArea:{clickable:!0,color:this._options.completedColor,weight:2,opacity:.9,fillColor:this._options.completedColor,fillOpacity:.2,className:"layer-measure-resultarea"},resultLine:{clickable:!0,color:this._options.completedColor,weight:3,opacity:.9,fill:!1,className:"layer-measure-resultline"},resultPoint:{clickable:!0,radius:4,color:this._options.completedColor,weight:2,opacity:1,fillColor:this._options.completedColor,fillOpacity:.7,className:"layer-measure-resultpoint"}};return b[a]}}),b.exports=f},{color:6,underscore:22}],45:[function(a,b,c){b.exports={acres:{factor:24711e-8,display:"acres",decimals:2},feet:{factor:3.2808,display:"feet",decimals:0},kilometers:{factor:.001,display:"kilometers",decimals:2},hectares:{factor:1e-4,display:"hectares",decimals:2},meters:{factor:1,display:"meters",decimals:0},miles:{factor:3.2808/5280,display:"miles",decimals:2},sqfeet:{factor:10.7639,display:"sqfeet",decimals:0},sqmeters:{factor:1,display:"sqmeters",decimals:0},sqmiles:{factor:3.86102e-7,display:"sqmiles",decimals:2}}},{}]},{},[43]); \ No newline at end of file +u.rest=u.tail=u.drop=function(a,b,c){return m.call(a,null==b||c?1:b)},u.compact=function(a){return u.filter(a,u.identity)};var E=function(a,b,c,d){for(var e=[],f=0,g=d||0,h=B(a);g<%= i18n.__(\'startCreating\') %>
\n \n \n<%= i18n.__(\'lastPoint\') %>
\n<%= model.lastCoord.dms.y %> / <%= model.lastCoord.dms.x %>
\n<%= humanize.numberFormat(model.lastCoord.dd.y, 6) %> / <%= humanize.numberFormat(model.lastCoord.dd.x, 6) %>
\n<%= i18n.__(\'pathDistance\') %> <%= model.lengthDisplay %>
\n<%= i18n.__(\'area\') %> <%= model.areaDisplay %>
\n<%= model.lastCoord.dms.y %> / <%= model.lastCoord.dms.x %>
\n<%= humanize.numberFormat(model.lastCoord.dd.y, 6) %> / <%= humanize.numberFormat(model.lastCoord.dd.x, 6) %>
\n'),n=c.template('<%= model.lengthDisplay %>
\n'),o=c.template('<%= model.areaDisplay %>
\n<%= model.lengthDisplay %> <%= i18n.__(\'perimeter\') %>
\n'),p=new(a("i18n-2"))({devMode:!1,locales:{ca:a("./i18n/ca"),cn:a("./i18n/cn"),da:a("./i18n/da"),de:a("./i18n/de"),de_CH:a("./i18n/de_CH"),en:a("./i18n/en"),en_UK:a("./i18n/en_UK"),es:a("./i18n/es"),fa:a("./i18n/fa"),fil_PH:a("./i18n/fil_PH"),fr:a("./i18n/fr"),it:a("./i18n/it"),nl:a("./i18n/nl"),pl:a("./i18n/pl"),pt_BR:a("./i18n/pt_BR"),pt_PT:a("./i18n/pt_PT"),ru:a("./i18n/ru"),sv:a("./i18n/sv"),tr:a("./i18n/tr")}});d.Control.Measure=d.Control.extend({_className:"leaflet-control-measure",options:{units:{},position:"topright",primaryLengthUnit:"feet",secondaryLengthUnit:"miles",primaryAreaUnit:"acres",activeColor:"#ABE67E",completedColor:"#C8F2BE",captureZIndex:1e4,popupOptions:{className:"leaflet-measure-resultpopup",autoPanPadding:[10,10]}},initialize:function(a){d.setOptions(this,a),this.options.units=d.extend({},f,this.options.units),this._symbols=new j(c.pick(this.options,"activeColor","completedColor")),p.setLocale(this.options.localization)},onAdd:function(a){return this._map=a,this._latlngs=[],this._initLayout(),a.on("click",this._collapse,this),this._layer=d.layerGroup().addTo(a),this._container},onRemove:function(a){a.off("click",this._collapse,this),a.removeLayer(this._layer)},_initLayout:function(){var a,b,c,e,f=this._className,g=this._container=d.DomUtil.create("div",f);g.innerHTML=k({model:{className:f},i18n:p}),g.setAttribute("aria-haspopup",!0),d.Browser.touch?d.DomEvent.on(g,"click",d.DomEvent.stopPropagation):(d.DomEvent.disableClickPropagation(g),d.DomEvent.disableScrollPropagation(g)),a=this.$toggle=i(".js-toggle",g),this.$interaction=i(".js-interaction",g),b=i(".js-start",g),c=i(".js-cancel",g),e=i(".js-finish",g),this.$startPrompt=i(".js-startprompt",g),this.$measuringPrompt=i(".js-measuringprompt",g),this.$startHelp=i(".js-starthelp",g),this.$results=i(".js-results",g),this.$measureTasks=i(".js-measuretasks",g),this._collapse(),this._updateMeasureNotStarted(),d.Browser.android||(d.DomEvent.on(g,"mouseenter",this._expand,this),d.DomEvent.on(g,"mouseleave",this._collapse,this)),d.DomEvent.on(a,"click",d.DomEvent.stop),d.Browser.touch?d.DomEvent.on(a,"click",this._expand,this):d.DomEvent.on(a,"focus",this._expand,this),d.DomEvent.on(b,"click",d.DomEvent.stop),d.DomEvent.on(b,"click",this._startMeasure,this),d.DomEvent.on(c,"click",d.DomEvent.stop),d.DomEvent.on(c,"click",this._finishMeasure,this),d.DomEvent.on(e,"click",d.DomEvent.stop),d.DomEvent.on(e,"click",this._handleMeasureDoubleClick,this); +},_expand:function(){h.hide(this.$toggle),h.show(this.$interaction)},_collapse:function(){this._locked||(h.hide(this.$interaction),h.show(this.$toggle))},_updateMeasureNotStarted:function(){h.hide(this.$startHelp),h.hide(this.$results),h.hide(this.$measureTasks),h.hide(this.$measuringPrompt),h.show(this.$startPrompt)},_updateMeasureStartedNoPoints:function(){h.hide(this.$results),h.show(this.$startHelp),h.show(this.$measureTasks),h.hide(this.$startPrompt),h.show(this.$measuringPrompt)},_updateMeasureStartedWithPoints:function(){h.hide(this.$startHelp),h.show(this.$results),h.show(this.$measureTasks),h.hide(this.$startPrompt),h.show(this.$measuringPrompt)},_startMeasure:function(){this._locked=!0,this._measureVertexes=d.featureGroup().addTo(this._layer),this._captureMarker=d.marker(this._map.getCenter(),{clickable:!0,zIndexOffset:this.options.captureZIndex,opacity:0}).addTo(this._layer),this._setCaptureMarkerIcon(),this._captureMarker.on("mouseout",this._handleMapMouseOut,this).on("dblclick",this._handleMeasureDoubleClick,this).on("click",this._handleMeasureClick,this),this._map.on("mousemove",this._handleMeasureMove,this).on("mouseout",this._handleMapMouseOut,this).on("move",this._centerCaptureMarker,this).on("resize",this._setCaptureMarkerIcon,this),d.DomEvent.on(this._container,"mouseenter",this._handleMapMouseOut,this),this._updateMeasureStartedNoPoints(),this._map.fire("measurestart",null,!1)},_finishMeasure:function(){var a=c.extend({},this._resultsModel,{points:this._latlngs});this._locked=!1,d.DomEvent.off(this._container,"mouseover",this._handleMapMouseOut,this),this._clearMeasure(),this._captureMarker.off("mouseout",this._handleMapMouseOut,this).off("dblclick",this._handleMeasureDoubleClick,this).off("click",this._handleMeasureClick,this),this._map.off("mousemove",this._handleMeasureMove,this).off("mouseout",this._handleMapMouseOut,this).off("move",this._centerCaptureMarker,this).off("resize",this._setCaptureMarkerIcon,this),this._layer.removeLayer(this._measureVertexes).removeLayer(this._captureMarker),this._measureVertexes=null,this._updateMeasureNotStarted(),this._collapse(),this._map.fire("measurefinish",a,!1)},_clearMeasure:function(){this._latlngs=[],this._resultsModel=null,this._measureVertexes.clearLayers(),this._measureDrag&&this._layer.removeLayer(this._measureDrag),this._measureArea&&this._layer.removeLayer(this._measureArea),this._measureBoundary&&this._layer.removeLayer(this._measureBoundary),this._measureDrag=null,this._measureArea=null,this._measureBoundary=null},_centerCaptureMarker:function(){this._captureMarker.setLatLng(this._map.getCenter())},_setCaptureMarkerIcon:function(){this._captureMarker.setIcon(d.divIcon({iconSize:this._map.getSize().multiplyBy(2)}))},_getMeasurementDisplayStrings:function(a){function b(a,b,e,f,g){var h;return b&&d[b]?(h=c(a,d[b],f,g),e&&d[e]&&(h=h+" ("+c(a,d[e],f,g)+")")):h=c(a,null,f,g),h}function c(a,b,c,d){return b&&b.factor&&b.display?e.numberFormat(a*b.factor,b.decimals||0,c||p.__("decPoint"),d||p.__("thousandsSep"))+" "+p.__([b.display])||b.display:e.numberFormat(a,0,c||p.__("decPoint"),d||p.__("thousandsSep"))}var d=this.options.units;return{lengthDisplay:b(a.length,this.options.primaryLengthUnit,this.options.secondaryLengthUnit,this.options.decPoint,this.options.thousandsSep),areaDisplay:b(a.area,this.options.primaryAreaUnit,this.options.secondaryAreaUnit,this.options.decPoint,this.options.thousandsSep)}},_updateResults:function(){var a=g.measure(this._latlngs),b=this._resultsModel=c.extend({},a,this._getMeasurementDisplayStrings(a),{pointCount:this._latlngs.length});this.$results.innerHTML=l({model:b,humanize:e,i18n:p})},_handleMeasureMove:function(a){this._measureDrag?this._measureDrag.setLatLng(a.latlng):this._measureDrag=d.circleMarker(a.latlng,this._symbols.getSymbol("measureDrag")).addTo(this._layer),this._measureDrag.bringToFront()},_handleMeasureDoubleClick:function(){var a,b,f,h,j,k,l=this._latlngs;this._finishMeasure(),l.length&&(l.length>2&&l.push(c.first(l)),a=g.measure(l),1===l.length?(b=d.circleMarker(l[0],this._symbols.getSymbol("resultPoint")),h=m({model:a,humanize:e,i18n:p})):2===l.length?(b=d.polyline(l,this._symbols.getSymbol("resultLine")),h=n({model:c.extend({},a,this._getMeasurementDisplayStrings(a)),humanize:e,i18n:p})):(b=d.polygon(l,this._symbols.getSymbol("resultArea")),h=o({model:c.extend({},a,this._getMeasurementDisplayStrings(a)),humanize:e,i18n:p})),f=d.DomUtil.create("div",""),f.innerHTML=h,j=i(".js-zoomto",f),j&&(d.DomEvent.on(j,"click",d.DomEvent.stop),d.DomEvent.on(j,"click",function(){b.getBounds?this._map.fitBounds(b.getBounds(),{padding:[20,20],maxZoom:17}):b.getLatLng&&this._map.panTo(b.getLatLng())},this)),k=i(".js-deletemarkup",f),k&&(d.DomEvent.on(k,"click",d.DomEvent.stop),d.DomEvent.on(k,"click",function(){this._layer.removeLayer(b)},this)),b.addTo(this._layer),b.bindPopup(f,this.options.popupOptions),b.getBounds?b.openPopup(b.getBounds().getCenter()):b.getLatLng&&b.openPopup(b.getLatLng()))},_handleMeasureClick:function(a){var b=this._map.mouseEventToLatLng(a.originalEvent),d=c.last(this._latlngs),e=this._symbols.getSymbol("measureVertex");d&&b.equals(d)||(this._latlngs.push(b),this._addMeasureArea(this._latlngs),this._addMeasureBoundary(this._latlngs),this._measureVertexes.eachLayer(function(a){a.setStyle(e),a._path.setAttribute("class",e.className)}),this._addNewVertex(b),this._measureBoundary&&this._measureBoundary.bringToFront(),this._measureVertexes.bringToFront()),this._updateResults(),this._updateMeasureStartedWithPoints()},_handleMapMouseOut:function(){this._measureDrag&&(this._layer.removeLayer(this._measureDrag),this._measureDrag=null)},_addNewVertex:function(a){d.circleMarker(a,this._symbols.getSymbol("measureVertexActive")).addTo(this._measureVertexes)},_addMeasureArea:function(a){return a.length<3?void(this._measureArea&&(this._layer.removeLayer(this._measureArea),this._measureArea=null)):void(this._measureArea?this._measureArea.setLatLngs(a):this._measureArea=d.polygon(a,this._symbols.getSymbol("measureArea")).addTo(this._layer))},_addMeasureBoundary:function(a){return a.length<2?void(this._measureBoundary&&(this._layer.removeLayer(this._measureBoundary),this._measureBoundary=null)):void(this._measureBoundary?this._measureBoundary.setLatLngs(a):this._measureBoundary=d.polyline(a,this._symbols.getSymbol("measureBoundary")).addTo(this._layer))}}),d.Map.mergeOptions({measureControl:!1}),d.Map.addInitHook(function(){this.options.measureControl&&(this.measureControl=(new d.Control.Measure).addTo(this))}),d.control.measure=function(a){return new d.Control.Measure(a)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./calc":23,"./dom":24,"./i18n/ca":25,"./i18n/cn":26,"./i18n/da":27,"./i18n/de":28,"./i18n/de_CH":29,"./i18n/en":30,"./i18n/en_UK":31,"./i18n/es":32,"./i18n/fa":33,"./i18n/fil_PH":34,"./i18n/fr":35,"./i18n/it":36,"./i18n/nl":37,"./i18n/pl":38,"./i18n/pt_BR":39,"./i18n/pt_PT":40,"./i18n/ru":41,"./i18n/sv":42,"./i18n/tr":43,"./mapsymbology":45,"./units":46,humanize:16,"i18n-2":18,underscore:22}],45:[function(a,b,c){var d=a("underscore"),e=a("color"),f=function(a){this.setOptions(a)};f.DEFAULTS={activeColor:"#ABE67E",completedColor:"#C8F2BE"},d.extend(f.prototype,{setOptions:function(a){return this._options=d.extend({},f.DEFAULTS,this._options,a),this},getSymbol:function(a){var b={measureDrag:{clickable:!1,radius:4,color:this._options.activeColor,weight:2,opacity:.7,fillColor:this._options.activeColor,fillOpacity:.5,className:"layer-measuredrag"},measureArea:{clickable:!1,stroke:!1,fillColor:this._options.activeColor,fillOpacity:.2,className:"layer-measurearea"},measureBoundary:{clickable:!1,color:this._options.activeColor,weight:2,opacity:.9,fill:!1,className:"layer-measureboundary"},measureVertex:{clickable:!1,radius:4,color:this._options.activeColor,weight:2,opacity:1,fillColor:this._options.activeColor,fillOpacity:.7,className:"layer-measurevertex"},measureVertexActive:{clickable:!1,radius:4,color:this._options.activeColor,weight:2,opacity:1,fillColor:e(this._options.activeColor).darken(.15),fillOpacity:.7,className:"layer-measurevertex active"},resultArea:{clickable:!0,color:this._options.completedColor,weight:2,opacity:.9,fillColor:this._options.completedColor,fillOpacity:.2,className:"layer-measure-resultarea"},resultLine:{clickable:!0,color:this._options.completedColor,weight:3,opacity:.9,fill:!1,className:"layer-measure-resultline"},resultPoint:{clickable:!0,radius:4,color:this._options.completedColor,weight:2,opacity:1,fillColor:this._options.completedColor,fillOpacity:.7,className:"layer-measure-resultpoint"}};return b[a]}}),b.exports=f},{color:6,underscore:22}],46:[function(a,b,c){b.exports={acres:{factor:24711e-8,display:"acres",decimals:2},feet:{factor:3.2808,display:"feet",decimals:0},kilometers:{factor:.001,display:"kilometers",decimals:2},hectares:{factor:1e-4,display:"hectares",decimals:2},meters:{factor:1,display:"meters",decimals:0},miles:{factor:3.2808/5280,display:"miles",decimals:2},sqfeet:{factor:10.7639,display:"sqfeet",decimals:0},sqmeters:{factor:1,display:"sqmeters",decimals:0},sqmiles:{factor:3.86102e-7,display:"sqmiles",decimals:2}}},{}]},{},[44]); \ No newline at end of file diff --git a/inst/htmlwidgets/lib/leaflet-omnivore/leaflet-omnivore.js b/inst/htmlwidgets/lib/leaflet-omnivore/leaflet-omnivore.js deleted file mode 100644 index 508192d03..000000000 --- a/inst/htmlwidgets/lib/leaflet-omnivore/leaflet-omnivore.js +++ /dev/null @@ -1,2382 +0,0 @@ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.omnivore = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o