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 -[![Build Status](https://travis-ci.org/rstudio/leaflet.svg)](https://travis-ci.org/rstudio/leaflet) +[![Build Status](https://travis-ci.org/rstudio/leaflet.svg?branch=master)](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("
" + options.na_label + "
"); } })(); } else { - if (options.na_color) { + if (options.na_color && _jquery2.default.inArray(options.na_label, labels) < 0) { colors.push(options.na_color); labels.push(options.na_label); } diff --git a/inst/htmlwidgets/leaflet.yaml b/inst/htmlwidgets/leaflet.yaml index c8ade5533..c36e524a2 100644 --- a/inst/htmlwidgets/leaflet.yaml +++ b/inst/htmlwidgets/leaflet.yaml @@ -4,7 +4,7 @@ dependencies: src: "htmlwidgets/lib/jquery" script: jquery.min.js - name: leaflet - version: 1.0.3 + version: 1.2.0 src: "htmlwidgets/lib/leaflet" script: leaflet.js stylesheet: leaflet.css diff --git a/inst/htmlwidgets/lib/leaflet-measure/leaflet-measure.js b/inst/htmlwidgets/lib/leaflet-measure/leaflet-measure.js index c678e4945..90c482d21 100644 --- a/inst/htmlwidgets/lib/leaflet-measure/leaflet-measure.js +++ b/inst/htmlwidgets/lib/leaflet-measure/leaflet-measure.js @@ -6954,6 +6954,41 @@ module.exports = { }; },{}],42:[function(require,module,exports){ +// sv.js +// Swedish (svenska) i18n translations + +module.exports = { + 'measure': 'Mäta', + 'measureDistancesAndAreas': 'Mäta avstånd och yta', + 'createNewMeasurement': 'Skapa ny mätning', + 'startCreating': 'Börja mätning genom att lägga till punkter på kartan', + 'finishMeasurement': 'Avsluta mätning', + 'lastPoint': 'Sista punkt', + 'area': 'Yta', + 'perimeter': 'Omkrets', + 'pointLocation': 'Punktens Läge', + 'areaMeasurement': 'Arealmätning', + 'linearMeasurement': 'Längdmätning', + 'pathDistance': 'Total linjelängd', + 'centerOnArea': 'Centrera på detta område', + 'centerOnLine': 'Centrera på denna linje', + 'centerOnLocation': 'Centrera på denna punkt', + 'cancel': 'Avbryt', + 'delete': 'Radera', + 'acres': 'Tunnland', + 'feet': 'Fot', + 'kilometers': 'Kilometer', + 'hectares': 'Hektar', + 'meters': 'Meter', + 'miles': 'Miles', + 'sqfeet': 'Kvadratfot', + 'sqmeters': 'Kvadratmeter', + 'sqmiles': 'Kvadratmiles', + 'decPoint': ',', + 'thousandsSep': ' ' //space +}; + +},{}],43:[function(require,module,exports){ // tr.js // Turkish i18n translations @@ -6988,7 +7023,7 @@ module.exports = { 'thousandsSep': ',' }; -},{}],43:[function(require,module,exports){ +},{}],44:[function(require,module,exports){ (function (global){ // leaflet-measure.js @@ -7030,6 +7065,7 @@ var i18n = new (require('i18n-2'))({ 'pt_BR': require('./i18n/pt_BR'), 'pt_PT': require('./i18n/pt_PT'), 'ru': require('./i18n/ru'), + 'sv': require('./i18n/sv'), 'tr': require('./i18n/tr') } }); @@ -7340,10 +7376,14 @@ L.Control.Measure = L.Control.extend({ if (zoomLink) { L.DomEvent.on(zoomLink, 'click', L.DomEvent.stop); L.DomEvent.on(zoomLink, 'click', function () { - this._map.fitBounds(resultFeature.getBounds(), { - padding: [20, 20], - maxZoom: 17 - }); + if (resultFeature.getBounds) { + this._map.fitBounds(resultFeature.getBounds(), { + padding: [20, 20], + maxZoom: 17 + }); + } else if (resultFeature.getLatLng) { + this._map.panTo(resultFeature.getLatLng()); + } }, this); } @@ -7358,7 +7398,11 @@ L.Control.Measure = L.Control.extend({ resultFeature.addTo(this._layer); resultFeature.bindPopup(popupContainer, this.options.popupOptions); - resultFeature.openPopup(resultFeature.getBounds().getCenter()); + if (resultFeature.getBounds) { + resultFeature.openPopup(resultFeature.getBounds().getCenter()); + } else if (resultFeature.getLatLng) { + resultFeature.openPopup(resultFeature.getLatLng()); + } }, // handle map click during ongoing measurement // add new clicked point, update measure layers and results ui @@ -7448,7 +7492,7 @@ L.control.measure = function (options) { }; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? 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(require,module,exports){ +},{"./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(require,module,exports){ // mapsymbology.js var _ = require('underscore'); @@ -7549,7 +7593,7 @@ _.extend(Symbology.prototype, { }); module.exports = Symbology; -},{"color":6,"underscore":22}],45:[function(require,module,exports){ +},{"color":6,"underscore":22}],46:[function(require,module,exports){ // units.js // Unit configurations // Factor is with respect to meters/sqmeters @@ -7601,4 +7645,4 @@ module.exports = { decimals: 2 } }; -},{}]},{},[43]); +},{}]},{},[44]); diff --git a/inst/htmlwidgets/lib/leaflet-measure/leaflet-measure.min.js b/inst/htmlwidgets/lib/leaflet-measure/leaflet-measure.min.js index 33901c713..1dfe9e231 100644 --- a/inst/htmlwidgets/lib/leaflet-measure/leaflet-measure.min.js +++ b/inst/htmlwidgets/lib/leaflet-measure/leaflet-measure.min.js @@ -1,4 +1,4 @@ !function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g.04045?Math.pow((b+.055)/1.055,2.4):b/12.92,c=c>.04045?Math.pow((c+.055)/1.055,2.4):c/12.92,d=d>.04045?Math.pow((d+.055)/1.055,2.4):d/12.92;var e=.4124*b+.3576*c+.1805*d,f=.2126*b+.7152*c+.0722*d,g=.0193*b+.1192*c+.9505*d;return[100*e,100*f,100*g]}function l(a){var b,c,d,e=k(a),f=e[0],g=e[1],h=e[2];return f/=95.047,g/=100,h/=108.883,f=f>.008856?Math.pow(f,1/3):7.787*f+16/116,g=g>.008856?Math.pow(g,1/3):7.787*g+16/116,h=h>.008856?Math.pow(h,1/3):7.787*h+16/116,b=116*g-16,c=500*(f-g),d=200*(g-h),[b,c,d]}function m(a){return M(l(a))}function n(a){var b,c,d,e,f,g=a[0]/360,h=a[1]/100,i=a[2]/100;if(0==h)return f=255*i,[f,f,f];c=i<.5?i*(1+h):i+h-i*h,b=2*i-c,e=[0,0,0];for(var j=0;j<3;j++)d=g+1/3*-(j-1),d<0&&d++,d>1&&d--,f=6*d<1?b+6*(c-b)*d:2*d<1?c:3*d<2?b+(c-b)*(2/3-d)*6:b,e[j]=255*f;return e}function o(a){var b,c,d=a[0],e=a[1]/100,f=a[2]/100;return 0===f?[0,0,0]:(f*=2,e*=f<=1?f:2-f,c=(f+e)/2,b=2*e/(f+e),[d,100*b,100*c])}function p(a){return h(n(a))}function q(a){return i(n(a))}function s(a){return j(n(a))}function t(a){var b=a[0]/60,c=a[1]/100,d=a[2]/100,e=Math.floor(b)%6,f=b-Math.floor(b),g=255*d*(1-c),h=255*d*(1-c*f),i=255*d*(1-c*(1-f)),d=255*d;switch(e){case 0:return[d,i,g];case 1:return[h,d,g];case 2:return[g,d,i];case 3:return[g,h,d];case 4:return[i,g,d];case 5:return[d,g,h]}}function u(a){var b,c,d=a[0],e=a[1]/100,f=a[2]/100;return c=(2-e)*f,b=e*f,b/=c<=1?c:2-c,b=b||0,c/=2,[d,100*b,100*c]}function v(a){return h(t(a))}function w(a){return i(t(a))}function x(a){return j(t(a))}function y(a){var c,d,e,f,h=a[0]/360,i=a[1]/100,j=a[2]/100,k=i+j;switch(k>1&&(i/=k,j/=k),c=Math.floor(6*h),d=1-j,e=6*h-c,0!=(1&c)&&(e=1-e),f=i+e*(d-i),c){default:case 6:case 0:r=d,g=f,b=i;break;case 1:r=f,g=d,b=i;break;case 2:r=i,g=d,b=f;break;case 3:r=i,g=f,b=d;break;case 4:r=f,g=i,b=d;break;case 5:r=d,g=i,b=f}return[255*r,255*g,255*b]}function z(a){return e(y(a))}function A(a){return f(y(a))}function B(a){return i(y(a))}function C(a){return j(y(a))}function D(a){var b,c,d,e=a[0]/100,f=a[1]/100,g=a[2]/100,h=a[3]/100;return b=1-Math.min(1,e*(1-h)+h),c=1-Math.min(1,f*(1-h)+h),d=1-Math.min(1,g*(1-h)+h),[255*b,255*c,255*d]}function E(a){return e(D(a))}function F(a){return f(D(a))}function G(a){return h(D(a))}function H(a){return j(D(a))}function I(a){var b,c,d,e=a[0]/100,f=a[1]/100,g=a[2]/100;return b=3.2406*e+f*-1.5372+g*-.4986,c=e*-.9689+1.8758*f+.0415*g,d=.0557*e+f*-.204+1.057*g,b=b>.0031308?1.055*Math.pow(b,1/2.4)-.055:b*=12.92,c=c>.0031308?1.055*Math.pow(c,1/2.4)-.055:c*=12.92,d=d>.0031308?1.055*Math.pow(d,1/2.4)-.055:d*=12.92,b=Math.min(Math.max(0,b),1),c=Math.min(Math.max(0,c),1),d=Math.min(Math.max(0,d),1),[255*b,255*c,255*d]}function J(a){var b,c,d,e=a[0],f=a[1],g=a[2];return e/=95.047,f/=100,g/=108.883,e=e>.008856?Math.pow(e,1/3):7.787*e+16/116,f=f>.008856?Math.pow(f,1/3):7.787*f+16/116,g=g>.008856?Math.pow(g,1/3):7.787*g+16/116,b=116*f-16,c=500*(e-f),d=200*(f-g),[b,c,d]}function K(a){return M(J(a))}function L(a){var b,c,d,e,f=a[0],g=a[1],h=a[2];return f<=8?(c=100*f/903.3,e=7.787*(c/100)+16/116):(c=100*Math.pow((f+16)/116,3),e=Math.pow(c/100,1/3)),b=b/95.047<=.008856?b=95.047*(g/500+e-16/116)/7.787:95.047*Math.pow(g/500+e,3),d=d/108.883<=.008859?d=108.883*(e-h/200-16/116)/7.787:108.883*Math.pow(e-h/200,3),[b,c,d]}function M(a){var b,c,d,e=a[0],f=a[1],g=a[2];return b=Math.atan2(g,f),c=360*b/2/Math.PI,c<0&&(c+=360),d=Math.sqrt(f*f+g*g),[e,d,c]}function N(a){return I(L(a))}function O(a){var b,c,d,e=a[0],f=a[1],g=a[2];return d=g/360*2*Math.PI,b=f*Math.cos(d),c=f*Math.sin(d),[e,b,c]}function P(a){return L(O(a))}function Q(a){return N(O(a))}function R(a){return Y[a]}function S(a){return e(R(a))}function T(a){return f(R(a))}function U(a){return h(R(a))}function V(a){return i(R(a))}function W(a){return l(R(a))}function X(a){return k(R(a))}c.exports={rgb2hsl:e,rgb2hsv:f,rgb2hwb:h,rgb2cmyk:i,rgb2keyword:j,rgb2xyz:k,rgb2lab:l,rgb2lch:m,hsl2rgb:n,hsl2hsv:o,hsl2hwb:p,hsl2cmyk:q,hsl2keyword:s,hsv2rgb:t,hsv2hsl:u,hsv2hwb:v,hsv2cmyk:w,hsv2keyword:x,hwb2rgb:y,hwb2hsl:z,hwb2hsv:A,hwb2cmyk:B,hwb2keyword:C,cmyk2rgb:D,cmyk2hsl:E,cmyk2hsv:F,cmyk2hwb:G,cmyk2keyword:H,keyword2rgb:R,keyword2hsl:S,keyword2hsv:T,keyword2hwb:U,keyword2cmyk:V,keyword2lab:W,keyword2xyz:X,xyz2rgb:I,xyz2lab:J,xyz2lch:K,lab2xyz:L,lab2rgb:N,lab2lch:M,lch2lab:O,lch2xyz:P,lch2rgb:Q};var Y={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},Z={};for(var $ in Y)Z[JSON.stringify(Y[$])]=$},{}],3:[function(a,b,c){var d=a("./conversions"),e=function(){return new j};for(var f in d){e[f+"Raw"]=function(a){return function(b){return"number"==typeof b&&(b=Array.prototype.slice.call(arguments)),d[a](b)}}(f);var g=/(\w+)2(\w+)/.exec(f),h=g[1],i=g[2];e[h]=e[h]||{},e[h][i]=e[f]=function(a){return function(b){"number"==typeof b&&(b=Array.prototype.slice.call(arguments));var c=d[a](b);if("string"==typeof c||void 0===c)return c;for(var e=0;ec?(b+.05)/(c+.05):(c+.05)/(b+.05)},level:function(a){var b=this.contrast(a);return b>=7.1?"AAA":b>=4.5?"AA":""},dark:function(){var a=this.values.rgb,b=(299*a[0]+587*a[1]+114*a[2])/1e3;return b<128},light:function(){return!this.dark()},negate:function(){for(var a=[],b=0;b<3;b++)a[b]=255-this.values.rgb[b];return this.setValues("rgb",a),this},lighten:function(a){return this.values.hsl[2]+=this.values.hsl[2]*a,this.setValues("hsl",this.values.hsl),this},darken:function(a){return this.values.hsl[2]-=this.values.hsl[2]*a,this.setValues("hsl",this.values.hsl),this},saturate:function(a){return this.values.hsl[1]+=this.values.hsl[1]*a,this.setValues("hsl",this.values.hsl),this},desaturate:function(a){return this.values.hsl[1]-=this.values.hsl[1]*a,this.setValues("hsl",this.values.hsl),this},whiten:function(a){return this.values.hwb[1]+=this.values.hwb[1]*a,this.setValues("hwb",this.values.hwb),this},blacken:function(a){return this.values.hwb[2]+=this.values.hwb[2]*a,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var a=this.values.rgb,b=.3*a[0]+.59*a[1]+.11*a[2];return this.setValues("rgb",[b,b,b]),this},clearer:function(a){return this.setValues("alpha",this.values.alpha-this.values.alpha*a),this},opaquer:function(a){return this.setValues("alpha",this.values.alpha+this.values.alpha*a),this},rotate:function(a){var b=this.values.hsl[0];return b=(b+a)%360,b=b<0?360+b:b,this.values.hsl[0]=b,this.setValues("hsl",this.values.hsl),this},mix:function(a,b){b=1-(null==b?.5:b);for(var c=2*b-1,d=this.alpha()-a.alpha(),e=((c*d==-1?c:(c+d)/(1+c*d))+1)/2,f=1-e,g=this.rgbArray(),h=a.rgbArray(),i=0;i0&&(c+=h(this._coords[a-1],this._coords[a]));this._calcedDistance=c}},distance:function(a){var b=d.extend({units:"meters"},a);if(this._internalDistanceCalc(),d.isFunction(g[b.units]))return g[b.units](this._calcedDistance)}}},{"./constants":9,"./units":14,underscore:15}],11:[function(a,b,c){var d=a("underscore");b.exports=function(a){return d.map(a,function(a){return[a[1],a[0]]})}},{underscore:15}],12:[function(a,b,c){var d=a("underscore"),e=a("./path"),f=a("./distance"),g=a("./area");d.extend(e.prototype,f,g),c.path=function(a,b){return new e(a,b)}},{"./area":8,"./distance":10,"./path":13,underscore:15}],13:[function(a,b,c){var d=a("./flipcoords"),e=function(a,b){this._options=b||{},a=a||[],this._coords=this._options.imBackwards===!0?d(a):a};b.exports=e},{"./flipcoords":11}],14:[function(a,b,c){c.meters={toFeet:function(a){return 3.28084*a},toKilometers:function(a){return.001*a},toMiles:function(a){return 621371e-9*a}},c.sqMeters={toSqMiles:function(a){return 3.86102e-7*a},toAcres:function(a){return 247105e-9*a}},c.degrees={toRadians:function(a){return a*Math.PI/180}}},{}],15:[function(a,b,c){(function(){var a=this,d=a._,e={},f=Array.prototype,g=Object.prototype,h=Function.prototype,i=f.push,j=f.slice,k=f.concat,l=g.toString,m=g.hasOwnProperty,n=f.forEach,o=f.map,p=f.reduce,q=f.reduceRight,r=f.filter,s=f.every,t=f.some,u=f.indexOf,v=f.lastIndexOf,w=Array.isArray,x=Object.keys,y=h.bind,z=function(a){return a instanceof z?a:this instanceof z?void(this._wrapped=a):new z(a)};"undefined"!=typeof c?("undefined"!=typeof b&&b.exports&&(c=b.exports=z),c._=z):a._=z,z.VERSION="1.5.2";var A=z.each=z.forEach=function(a,b,c){if(null!=a)if(n&&a.forEach===n)a.forEach(b,c);else if(a.length===+a.length){for(var d=0,f=a.length;d2;if(null==a&&(a=[]),p&&a.reduce===p)return d&&(b=z.bind(b,d)),e?a.reduce(b,c):a.reduce(b);if(A(a,function(a,f,g){e?c=b.call(d,c,a,f,g):(c=a,e=!0)}),!e)throw new TypeError(B);return c},z.reduceRight=z.foldr=function(a,b,c,d){var e=arguments.length>2;if(null==a&&(a=[]),q&&a.reduceRight===q)return d&&(b=z.bind(b,d)),e?a.reduceRight(b,c):a.reduceRight(b);var f=a.length;if(f!==+f){var g=z.keys(a);f=g.length}if(A(a,function(h,i,j){i=g?g[--f]:--f,e?c=b.call(d,c,a[i],i,j):(c=a[i],e=!0)}),!e)throw new TypeError(B);return c},z.find=z.detect=function(a,b,c){var d;return C(a,function(a,e,f){if(b.call(c,a,e,f))return d=a,!0}),d},z.filter=z.select=function(a,b,c){var d=[];return null==a?d:r&&a.filter===r?a.filter(b,c):(A(a,function(a,e,f){b.call(c,a,e,f)&&d.push(a)}),d)},z.reject=function(a,b,c){return z.filter(a,function(a,d,e){return!b.call(c,a,d,e)},c)},z.every=z.all=function(a,b,c){b||(b=z.identity);var d=!0;return null==a?d:s&&a.every===s?a.every(b,c):(A(a,function(a,f,g){if(!(d=d&&b.call(c,a,f,g)))return e}),!!d)};var C=z.some=z.any=function(a,b,c){b||(b=z.identity);var d=!1;return null==a?d:t&&a.some===t?a.some(b,c):(A(a,function(a,f,g){if(d||(d=b.call(c,a,f,g)))return e}),!!d)};z.contains=z.include=function(a,b){return null!=a&&(u&&a.indexOf===u?a.indexOf(b)!=-1:C(a,function(a){return a===b}))},z.invoke=function(a,b){var c=j.call(arguments,2),d=z.isFunction(b);return z.map(a,function(a){return(d?b:a[b]).apply(a,c)})},z.pluck=function(a,b){return z.map(a,function(a){return a[b]})},z.where=function(a,b,c){return z.isEmpty(b)?c?void 0:[]:z[c?"find":"filter"](a,function(a){for(var c in b)if(b[c]!==a[c])return!1;return!0})},z.findWhere=function(a,b){return z.where(a,b,!0)},z.max=function(a,b,c){if(!b&&z.isArray(a)&&a[0]===+a[0]&&a.length<65535)return Math.max.apply(Math,a);if(!b&&z.isEmpty(a))return-(1/0);var d={computed:-(1/0),value:-(1/0)};return A(a,function(a,e,f){var g=b?b.call(c,a,e,f):a;g>d.computed&&(d={value:a,computed:g})}),d.value},z.min=function(a,b,c){if(!b&&z.isArray(a)&&a[0]===+a[0]&&a.length<65535)return Math.min.apply(Math,a);if(!b&&z.isEmpty(a))return 1/0;var d={computed:1/0,value:1/0};return A(a,function(a,e,f){var g=b?b.call(c,a,e,f):a;gd||void 0===c)return 1;if(c>>1;c.call(d,a[h])=0}); })},z.difference=function(a){var b=k.apply(f,j.call(arguments,1));return z.filter(a,function(a){return!z.contains(b,a)})},z.zip=function(){for(var a=z.max(z.pluck(arguments,"length").concat(0)),b=new Array(a),c=0;c=0;c--)b=[a[c].apply(this,b)];return b[0]}},z.after=function(a,b){return function(){if(--a<1)return b.apply(this,arguments)}},z.keys=x||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var b=[];for(var c in a)z.has(a,c)&&b.push(c);return b},z.values=function(a){for(var b=z.keys(a),c=b.length,d=new Array(c),e=0;e":">",'"':""","'":"'"}};I.unescape=z.invert(I.escape);var J={escape:new RegExp("["+z.keys(I.escape).join("")+"]","g"),unescape:new RegExp("("+z.keys(I.unescape).join("|")+")","g")};z.each(["escape","unescape"],function(a){z[a]=function(b){return null==b?"":(""+b).replace(J[a],function(b){return I[a][b]})}}),z.result=function(a,b){if(null!=a){var c=a[b];return z.isFunction(c)?c.call(a):c}},z.mixin=function(a){A(z.functions(a),function(b){var c=z[b]=a[b];z.prototype[b]=function(){var a=[this._wrapped];return i.apply(a,arguments),O.call(this,c.apply(z,a))}})};var K=0;z.uniqueId=function(a){var b=++K+"";return a?a+b:b},z.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var L=/(.)^/,M={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},N=/\\|'|\r|\n|\t|\u2028|\u2029/g;z.template=function(a,b,c){var d;c=z.defaults({},c,z.templateSettings);var e=new RegExp([(c.escape||L).source,(c.interpolate||L).source,(c.evaluate||L).source].join("|")+"|$","g"),f=0,g="__p+='";a.replace(e,function(b,c,d,e,h){return g+=a.slice(f,h).replace(N,function(a){return"\\"+M[a]}),c&&(g+="'+\n((__t=("+c+"))==null?'':_.escape(__t))+\n'"),d&&(g+="'+\n((__t=("+d+"))==null?'':__t)+\n'"),e&&(g+="';\n"+e+"\n__p+='"),f=h+b.length,b}),g+="';\n",c.variable||(g="with(obj||{}){\n"+g+"}\n"),g="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+g+"return __p;\n";try{d=new Function(c.variable||"obj","_",g)}catch(a){throw a.source=g,a}if(b)return d(b,z);var h=function(a){return d.call(this,a,z)};return h.source="function("+(c.variable||"obj")+"){\n"+g+"}",h},z.chain=function(a){return z(a).chain()};var O=function(a){return this._chain?z(a).chain():a};z.mixin(z),A(["pop","push","reverse","shift","sort","splice","unshift"],function(a){var b=f[a];z.prototype[a]=function(){var c=this._wrapped;return b.apply(c,arguments),"shift"!=a&&"splice"!=a||0!==c.length||delete c[0],O.call(this,c)}}),A(["concat","join","slice"],function(a){var b=f[a];z.prototype[a]=function(){return O.call(this,b.apply(this._wrapped,arguments))}}),z.extend(z.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this)},{}],16:[function(a,b,c){(function(){var a=this,d=a.humanize,e={};"undefined"!=typeof c?("undefined"!=typeof b&&b.exports&&(c=b.exports=e),c.humanize=e):("function"==typeof define&&define.amd&&define("humanize",function(){return e}),a.humanize=e),e.noConflict=function(){return a.humanize=d,this},e.pad=function(a,b,c,d){if(a+="",c?c.length>1&&(c=c.charAt(0)):c=" ",d=void 0===d?"left":"right","right"===d)for(;a.length4&&a<21?"th":{1:"st",2:"nd",3:"rd"}[a%10]||"th"},w:function(){return c.getDay()},z:function(){return(k.L()?g[k.n()]:f[k.n()])+k.j()-1},W:function(){var a=k.z()-k.N()+1.5;return e.pad(1+Math.floor(Math.abs(a)/7)+(a%7>3.5?1:0),2,"0")},F:function(){return j[c.getMonth()]},m:function(){return e.pad(k.n(),2,"0")},M:function(){return k.F().slice(0,3)},n:function(){return c.getMonth()+1},t:function(){return new Date(k.Y(),k.n(),0).getDate()},L:function(){return 1===new Date(k.Y(),1,29).getMonth()?1:0},o:function(){var a=k.n(),b=k.W();return k.Y()+(12===a&&b<9?-1:1===a&&b>9)},Y:function(){return c.getFullYear()},y:function(){return String(k.Y()).slice(-2)},a:function(){return c.getHours()>11?"pm":"am"},A:function(){return k.a().toUpperCase()},B:function(){var a=c.getTime()/1e3,b=a%86400+3600;b<0&&(b+=86400);var d=b/86.4%1e3;return a<0?Math.ceil(d):Math.floor(d)},g:function(){return k.G()%12||12},G:function(){return c.getHours()},h:function(){return e.pad(k.g(),2,"0")},H:function(){return e.pad(k.G(),2,"0")},i:function(){return e.pad(c.getMinutes(),2,"0")},s:function(){return e.pad(c.getSeconds(),2,"0")},u:function(){return e.pad(1e3*c.getMilliseconds(),6,"0")},O:function(){var a=c.getTimezoneOffset(),b=Math.abs(a);return(a>0?"-":"+")+e.pad(100*Math.floor(b/60)+b%60,4,"0")},P:function(){var a=k.O();return a.substr(0,3)+":"+a.substr(3,2)},Z:function(){return 60*-c.getTimezoneOffset()},c:function(){return"Y-m-d\\TH:i:sP".replace(d,h)},r:function(){return"D, d M Y H:i:s O".replace(d,h)},U:function(){return c.getTime()/1e3||0}};return a.replace(d,h)},e.numberFormat=function(a,b,c,d){b=isNaN(b)?2:Math.abs(b),c=void 0===c?".":c,d=void 0===d?",":d;var e=a<0?"-":"";a=Math.abs(+a||0);var f=parseInt(a.toFixed(b),10)+"",g=f.length>3?f.length%3:0;return e+(g?f.substr(0,g)+d:"")+f.substr(g).replace(/(\d{3})(?=\d)/g,"$1"+d)+(b?c+Math.abs(a-f).toFixed(b).slice(2):"")},e.naturalDay=function(a,b){a=void 0===a?e.time():a,b=void 0===b?"Y-m-d":b;var c=86400,d=new Date,f=new Date(d.getFullYear(),d.getMonth(),d.getDate()).getTime()/1e3;return a=f-c?"yesterday":a>=f&&a=f+c&&a-2)return(c>=0?"just ":"")+"now";if(c<60&&c>-60)return c>=0?Math.floor(c)+" seconds ago":"in "+Math.floor(-c)+" seconds";if(c<120&&c>-120)return c>=0?"about a minute ago":"in about a minute";if(c<3600&&c>-3600)return c>=0?Math.floor(c/60)+" minutes ago":"in "+Math.floor(-c/60)+" minutes";if(c<7200&&c>-7200)return c>=0?"about an hour ago":"in about an hour";if(c<86400&&c>-86400)return c>=0?Math.floor(c/3600)+" hours ago":"in "+Math.floor(-c/3600)+" hours";var d=172800;if(c-d)return c>=0?"1 day ago":"in 1 day";var f=2505600;if(c-f)return c>=0?Math.floor(c/86400)+" days ago":"in "+Math.floor(-c/86400)+" days";var g=5184e3;if(c-g)return c>=0?"about a month ago":"in about a month";var h=parseInt(e.date("Y",b),10),i=parseInt(e.date("Y",a),10),j=12*h+parseInt(e.date("n",b),10),k=12*i+parseInt(e.date("n",a),10),l=j-k;if(l<12&&l>-12)return l>=0?l+" months ago":"in "+-l+" months";var m=h-i;return m<2&&m>-2?m>=0?"a year ago":"in a year":m>=0?m+" years ago":"in "+-m+" years"},e.ordinal=function(a){a=parseInt(a,10),a=isNaN(a)?0:a;var b=a<0?"-":"";a=Math.abs(a);var c=a%100;return b+a+(c>4&&c<21?"th":{1:"st",2:"nd",3:"rd"}[a%10]||"th")},e.filesize=function(a,b,c,d,f,g){return b=void 0===b?1024:b,a<=0?"0 bytes":(a

"),a=a.replace(/\n/g,"
"),"

"+a+"

"},e.nl2br=function(a){return a.replace(/(\r\n|\n|\r)/g,"
")},e.truncatechars=function(a,b){return a.length<=b?a:a.substr(0,b)+"…"},e.truncatewords=function(a,b){var c=a.split(" ");return c.length1&&(a=e(a,Array.prototype.slice.call(arguments,1))),a},__n:function(a,b,c){var d;if("number"==typeof b){var f=a,g=b;d=this.translate(this.locale,f),d=e(parseInt(g,10)>1?d.other:d.one,Array.prototype.slice.call(arguments,1))}else{var h=a,i=b,g=c;d=this.translate(this.locale,h,i),d=e(parseInt(g,10)>1?d.other:d.one,[g]),arguments.length>3&&(d=e(d,Array.prototype.slice.call(arguments,3)))}return d},setLocale:function(a){if(a)return this.locales[a]||(this.devMode&&console.warn("Locale ("+a+") not found."),a=this.defaultLocale),this.locale=a},getLocale:function(){return this.locale},isPreferredLocale:function(){return!this.prefLocale||this.prefLocale===this.getLocale()},setLocaleFromSessionVar:function(a){if(a=a||this.request,a&&a.session&&a.session[this.sessionVarName]){var b=a.session[this.sessionVarName];this.locales[b]&&(this.devMode&&console.log("Overriding locale from query: "+b),this.setLocale(b))}},setLocaleFromQuery:function(a){if(a=a||this.request,a&&a.query&&a.query.lang){var b=(a.query.lang+"").toLowerCase();this.locales[b]&&(this.devMode&&console.log("Overriding locale from query: "+b),this.setLocale(b))}},setLocaleFromSubdomain:function(a){a=a||this.request,a&&a.headers&&a.headers.host&&/^([^.]+)/.test(a.headers.host)&&this.locales[RegExp.$1]&&(this.devMode&&console.log("Overriding locale from host: "+RegExp.$1),this.setLocale(RegExp.$1))},setLocaleFromCookie:function(a){if(a=a||this.request,a&&a.cookies&&this.cookieName&&a.cookies[this.cookieName]){var b=a.cookies[this.cookieName].toLowerCase();this.locales[b]&&(this.devMode&&console.log("Overriding locale from cookie: "+b),this.setLocale(b))}},setLocaleFromEnvironmentVariable:function(){if(c.env.LANG){var a=c.env.LANG.split("_")[0];this.locales[a]&&(this.devMode&&console.log("Overriding locale from environment variable: "+a),this.setLocale(a))}},preferredLocale:function(a){if(a=a||this.request,a&&a.headers){for(var b,c=a.headers["accept-language"]||"",d=/(^|,\s*)([a-z0-9-]+)/gi,e=this;!b&&(match=d.exec(c));){var f=match[2].toLowerCase(),g=f.split("-");e.locales[f]?b=f:g.length>1&&e.locales[g[0]]&&(b=g[0])}return b||this.defaultLocale}},translate:function(a,b,c){return a&&this.locales[a]||(this.devMode&&console.warn("WARN: No locale found. Using the default ("+this.defaultLocale+") as current locale"),a=this.defaultLocale,this.initLocale(a,{})),this.locales[a][b]||this.devMode&&(d(this.locales[a],b,c?{one:b,other:c}:void 0),this.writeFile(a)),d(this.locales[a],b,c?{one:b,other:c}:void 0)},readFile:function(a){var b=this.locateFile(a);if(!this.devMode&&h.localeCache[b])return void this.initLocale(a,h.localeCache[b]);try{var c,d=f.readFileSync(b);if("function"==typeof this.base){var e;try{e=this.base(a)}catch(b){console.error("base function threw exception for locale %s",a,b)}if("string"==typeof e)try{c=this.parse(f.readFileSync(this.locateFile(e)))}catch(b){console.error("unable to read or parse base file %s for locale %s",e,a,b)}}try{var g=this.parse(d);if(c){for(var i in g)c[i]=g[i];g=c}this.initLocale(a,g)}catch(a){console.error("unable to parse locales from file (maybe "+b+" is empty or invalid "+this.extension+"?): ",a)}}catch(c){f.existsSync(b)||this.writeFile(a)}},writeFile:function(a){if(!this.devMode)return void this.initLocale(a,{});try{f.lstatSync(this.directory)}catch(a){this.devMode&&console.log("creating locales dir in: "+this.directory),f.mkdirSync(this.directory,493)}this.initLocale(a,{});try{var b=this.locateFile(a),c=b+".tmp";f.writeFileSync(c,this.dump(this.locales[a],this.indent),"utf8"),f.statSync(c).isFile()?f.renameSync(c,b):console.error("unable to write locales to file (either "+c+" or "+b+" are not writeable?): ")}catch(a){console.error("unexpected error writing files (either "+c+" or "+b+" are not writeable?): ",a)}},locateFile:function(a){return g.normalize(this.directory+"/"+a+this.extension)},initLocale:function(a,b){if(!this.locales[a]&&(this.locales[a]=b,!this.devMode)){var c=this.locateFile(a);h.localeCache[c]||(h.localeCache[c]=b)}}}}).call(this,a("_process"))},{_process:20,fs:1,path:19,sprintf:21}],18:[function(a,b,c){b.exports=a("./i18n")},{"./i18n":17}],19:[function(a,b,c){(function(a){function b(a,b){for(var c=0,d=a.length-1;d>=0;d--){var e=a[d];"."===e?a.splice(d,1):".."===e?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c--;c)a.unshift("..");return a}function d(a,b){if(a.filter)return a.filter(b);for(var c=[],d=0;d=-1&&!e;f--){var g=f>=0?arguments[f]:a.cwd();if("string"!=typeof g)throw new TypeError("Arguments to path.resolve must be strings");g&&(c=g+"/"+c,e="/"===g.charAt(0))}return c=b(d(c.split("/"),function(a){return!!a}),!e).join("/"),(e?"/":"")+c||"."},c.normalize=function(a){var e=c.isAbsolute(a),f="/"===g(a,-1);return a=b(d(a.split("/"),function(a){return!!a}),!e).join("/"),a||e||(a="."),a&&f&&(a+="/"),(e?"/":"")+a},c.isAbsolute=function(a){return"/"===a.charAt(0)},c.join=function(){var a=Array.prototype.slice.call(arguments,0);return c.normalize(d(a,function(a,b){if("string"!=typeof a)throw new TypeError("Arguments to path.join must be strings");return a}).join("/"))},c.relative=function(a,b){function d(a){for(var b=0;b=0&&""===a[c];c--);return b>c?[]:a.slice(b,c-b+1)}a=c.resolve(a).substr(1),b=c.resolve(b).substr(1);for(var e=d(a.split("/")),f=d(b.split("/")),g=Math.min(e.length,f.length),h=g,i=0;i1)for(var c=1;c0;c[--b]=a);return c.join("")}var c=function(){return c.cache.hasOwnProperty(arguments[0])||(c.cache[arguments[0]]=c.parse(arguments[0])),c.format.call(null,c.cache[arguments[0]],arguments)};return c.object_stringify=function(a,b,d,e){var f="";if(null!=a)switch(typeof a){case"function":return"[Function"+(a.name?": "+a.name:"")+"]";case"object":if(a instanceof Error)return"["+a.toString()+"]";if(b>=d)return"[Object]";if(e&&(e=e.slice(0),e.push(a)),null!=a.length){f+="[";var g=[];for(var h in a)e&&e.indexOf(a[h])>=0?g.push("[Circular]"):g.push(c.object_stringify(a[h],b+1,d,e));f+=g.join(", ")+"]"}else{if("getMonth"in a)return"Date("+a+")";f+="{";var g=[];for(var i in a)a.hasOwnProperty(i)&&(e&&e.indexOf(a[i])>=0?g.push(i+": [Circular]"):g.push(i+": "+c.object_stringify(a[i],b+1,d,e)));f+=g.join(", ")+"}"}return f;case"string":return'"'+a+'"'}return""+a},c.format=function(e,f){var g,h,i,j,k,l,m,n=1,o=e.length,p="",q=[];for(h=0;h=0?"+"+g:g,l=j[4]?"0"==j[4]?"0":j[4].charAt(1):" ",m=j[6]-String(g).length,k=j[6]?b(l,m):"",q.push(j[5]?g+k:k+g)}return q.join("")},c.cache={},c.parse=function(a){for(var b=a,c=[],d=[],e=0;b;){if(null!==(c=/^[^\x25]+/.exec(b)))d.push(c[0]);else if(null!==(c=/^\x25{2}/.exec(b)))d.push("%");else{if(null===(c=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosOuxX])/.exec(b)))throw new Error("[sprintf] "+b);if(c[2]){e|=1;var f=[],g=c[2],h=[];if(null===(h=/^([a-z_][a-z_\d]*)/i.exec(g)))throw new Error("[sprintf] "+g);for(f.push(h[1]);""!==(g=g.substring(h[0].length));)if(null!==(h=/^\.([a-z_][a-z_\d]*)/i.exec(g)))f.push(h[1]);else{if(null===(h=/^\[(\d+)\]/.exec(g)))throw new Error("[sprintf] "+g);f.push(h[1])}c[2]=f}else e|=2;if(3===e)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");d.push(c)}b=b.substring(c[0].length)}return d},c}(),e=function(a,b){var c=b.slice();return c.unshift(a),d.apply(null,c)};b.exports=d,d.sprintf=d,d.vsprintf=e},{}],22:[function(a,b,c){(function(){function a(a){function b(b,c,d,e,f,g){for(;f>=0&&f0?0:h-1;return arguments.length<3&&(e=c[g?g[i]:i],i+=a),b(c,d,e,g,i,h)}}function d(a){return function(b,c,d){c=w(c,d);for(var e=B(b),f=a>0?0:e-1;f>=0&&f0?g=f>=0?f:Math.max(f+h,g):h=f>=0?Math.min(f+1,h):f+h+1;else if(c&&f&&h)return f=c(d,e),d[f]===e?f:-1;if(e!==e)return f=b(m.call(d,g,h),u.isNaN),f>=0?f+g:-1;for(f=a>0?g:h-1;f>=0&&f=0&&b<=A};u.each=u.forEach=function(a,b,c){b=v(b,c);var d,e;if(C(a))for(d=0,e=a.length;d=0},u.invoke=function(a,b){var c=m.call(arguments,2),d=u.isFunction(b);return u.map(a,function(a){var e=d?b:a[b];return null==e?e:e.apply(a,c)})},u.pluck=function(a,b){return u.map(a,u.property(b))},u.where=function(a,b){return u.filter(a,u.matcher(b))},u.findWhere=function(a,b){return u.find(a,u.matcher(b))},u.max=function(a,b,c){var d,e,f=-(1/0),g=-(1/0);if(null==b&&null!=a){a=C(a)?a:u.values(a);for(var h=0,i=a.length;hf&&(f=d)}else b=w(b,c),u.each(a,function(a,c,d){e=b(a,c,d),(e>g||e===-(1/0)&&f===-(1/0))&&(f=a,g=e)});return f},u.min=function(a,b,c){var d,e,f=1/0,g=1/0;if(null==b&&null!=a){a=C(a)?a:u.values(a);for(var h=0,i=a.length;hd||void 0===c)return 1;if(cb?(g&&(clearTimeout(g),g=null),h=j,f=a.apply(d,e),g||(d=e=null)):g||c.trailing===!1||(g=setTimeout(i,k)),f}},u.debounce=function(a,b,c){var d,e,f,g,h,i=function(){var j=u.now()-g;j=0?d=setTimeout(i,b-j):(d=null,c||(h=a.apply(f,e),d||(f=e=null)))};return function(){f=this,e=arguments,g=u.now();var j=c&&!d;return d||(d=setTimeout(i,b)),j&&(h=a.apply(f,e),f=e=null),h}},u.wrap=function(a,b){return u.partial(b,a)},u.negate=function(a){return function(){return!a.apply(this,arguments)}},u.compose=function(){var a=arguments,b=a.length-1;return function(){for(var c=b,d=a[b].apply(this,arguments);c--;)d=a[c].call(this,d);return d}},u.after=function(a,b){return function(){if(--a<1)return b.apply(this,arguments)}},u.before=function(a,b){var c;return function(){return--a>0&&(c=b.apply(this,arguments)),a<=1&&(b=null),c}},u.once=u.partial(u.before,2);var G=!{toString:null}.propertyIsEnumerable("toString"),H=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];u.keys=function(a){if(!u.isObject(a))return[];if(q)return q(a);var b=[];for(var c in a)u.has(a,c)&&b.push(c);return G&&f(a,b),b},u.allKeys=function(a){if(!u.isObject(a))return[];var b=[];for(var c in a)b.push(c);return G&&f(a,b),b},u.values=function(a){for(var b=u.keys(a),c=b.length,d=Array(c),e=0;e":">",'"':""","'":"'","`":"`"},K=u.invert(J),L=function(a){var b=function(b){return a[b]},c="(?:"+u.keys(a).join("|")+")",d=RegExp(c),e=RegExp(c,"g");return function(a){return a=null==a?"":""+a,d.test(a)?a.replace(e,b):a}};u.escape=L(J),u.unescape=L(K),u.result=function(a,b,c){var d=null==a?void 0:a[b];return void 0===d&&(d=c),u.isFunction(d)?d.call(a):d};var M=0;u.uniqueId=function(a){var b=++M+"";return a?a+b:b},u.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var N=/(.)^/,O={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},P=/\\|'|\r|\n|\u2028|\u2029/g,Q=function(a){return"\\"+O[a]};u.template=function(a,b,c){!b&&c&&(b=c),b=u.defaults({},b,u.templateSettings);var d=RegExp([(b.escape||N).source,(b.interpolate||N).source,(b.evaluate||N).source].join("|")+"|$","g"),e=0,f="__p+='";a.replace(d,function(b,c,d,g,h){return f+=a.slice(e,h).replace(P,Q),e=h+b.length,c?f+="'+\n((__t=("+c+"))==null?'':_.escape(__t))+\n'":d?f+="'+\n((__t=("+d+"))==null?'':__t)+\n'":g&&(f+="';\n"+g+"\n__p+='"),b}),f+="';\n",b.variable||(f="with(obj||{}){\n"+f+"}\n"),f="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+f+"return __p;\n";try{var g=new Function(b.variable||"obj","_",f)}catch(a){throw a.source=f,a}var h=function(a){return g.call(this,a,u)},i=b.variable||"obj";return h.source="function("+i+"){\n"+f+"}",h},u.chain=function(a){var b=u(a);return b._chain=!0,b};var R=function(a,b){return a._chain?u(b).chain():b};u.mixin=function(a){u.each(u.functions(a),function(b){var c=u[b]=a[b];u.prototype[b]=function(){var a=[this._wrapped];return l.apply(a,arguments),R(this,c.apply(u,a))}})},u.mixin(u),u.each(["pop","push","reverse","shift","sort","splice","unshift"],function(a){var b=i[a];u.prototype[a]=function(){var c=this._wrapped;return b.apply(c,arguments),"shift"!==a&&"splice"!==a||0!==c.length||delete c[0],R(this,c)}}),u.each(["concat","join","slice"],function(a){var b=i[a];u.prototype[a]=function(){return R(this,b.apply(this._wrapped,arguments))}}),u.prototype.value=function(){return this._wrapped},u.prototype.valueOf=u.prototype.toJSON=u.prototype.value,u.prototype.toString=function(){return""+this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return u})}).call(this)},{}],23:[function(a,b,c){var d=a("underscore"),e=a("geocrunch"),f=function(a){return a<10?"0"+a.toString():a.toString()},g=function(a,b,c){var d=Math.abs(a),e=Math.floor(d),g=Math.floor(60*(d-e)),h=Math.round(3600*(d-e-g/60)*100)/100,i=d===a?b:c;return f(e)+"° "+f(g)+"' "+f(h)+'" '+i},h=function(a){var b=d.last(a),c=e.path(d.map(a,function(a){return[a.lng,a.lat]})),f=c.distance({units:"meters"}),h=c.area({units:"sqmeters"});return{lastCoord:{dd:{x:b.lng,y:b.lat},dms:{x:g(b.lng,"E","W"),y:g(b.lat,"N","S")}},length:f,area:h}};b.exports={measure:h}},{geocrunch:7,underscore:22}],24:[function(a,b,c){var d=function(a,b){return b||(b=document),b.querySelector(a)},e=function(a,b){return b||(b=document),Array.prototype.slice.call(b.querySelectorAll(a))},f=function(a){if(a)return a.setAttribute("style","display:none;"),a},g=function(a){if(a)return a.removeAttribute("style"),a};b.exports={$:d,$$:e,hide:f,show:g}},{}],25:[function(a,b,c){b.exports={measure:"Medir",measureDistancesAndAreas:"Medeix distancies i àreas",createNewMeasurement:"Crear nova medicio",startCreating:"Començi a crear la medicio afegint punts al mapa",finishMeasurement:"Acabar la medició",lastPoint:"Últim punt",area:"Área",perimeter:"Perómetre",pointLocation:"Localizació del punt",areaMeasurement:"Medició d'área",linearMeasurement:"Medició lineal",pathDistance:"Distancia de ruta",centerOnArea:"Centrar en aquesta área",centerOnLine:"Centrar en aquesta línia",centerOnLocation:"Centrar en aquesta localizació",cancel:"Cancel·lar",delete:"Eliminar",acres:"Acres",feet:"Peus",kilometers:"Quilòmetres",hectares:"Hectàreas",meters:"Metros",miles:"Milles",sqfeet:"Peus cuadrats",sqmeters:"Metres cuadrats",sqmiles:"Milles cuadrades",decPoint:".",thousandsSep:" "}},{}],26:[function(a,b,c){b.exports={measure:"测量",measureDistancesAndAreas:"同时测量距离和面积",createNewMeasurement:"开始一次新的测量",startCreating:"点击地图加点以开始创建测量",finishMeasurement:"完成测量",lastPoint:"最后点的坐标",area:"面积",perimeter:"周长",pointLocation:"点的坐标",areaMeasurement:"面积测量",linearMeasurement:"距离测量",pathDistance:"路径长度",centerOnArea:"该面积居中",centerOnLine:"该线段居中",centerOnLocation:"该位置居中",cancel:"取消",delete:"删除",acres:"公亩",feet:"英尺",kilometers:"公里",hectares:"公顷",meters:"米",miles:"英里",sqfeet:"平方英尺",sqmeters:"平方米",sqmiles:"平方英里",decPoint:".",thousandsSep:","}},{}],27:[function(a,b,c){b.exports={measure:"Mål",measureDistancesAndAreas:"Mål afstande og arealer",createNewMeasurement:"Lav en ny måling",startCreating:"Begynd målingen ved at tilføje punkter på kortet",finishMeasurement:"Afslut måling",lastPoint:"Sidste punkt",area:"Areal",perimeter:"Omkreds",pointLocation:"Punkt",areaMeasurement:"Areal",linearMeasurement:"Linje",pathDistance:"Sti afstand",centerOnArea:"Centrér dette område",centerOnLine:"Centrér denne linje",centerOnLocation:"Centrér dette punkt",cancel:"Annuller",delete:"Slet",acres:"acre",feet:"fod",kilometers:"km",hectares:"ha",meters:"m",miles:"mil",sqfeet:"kvadratfod",sqmeters:"m²",sqmiles:"kvadratmil",decPoint:",",thousandsSep:"."}},{}],28:[function(a,b,c){b.exports={measure:"Messung",measureDistancesAndAreas:"Messung von Abständen und Flächen",createNewMeasurement:"Eine neue Messung durchführen",startCreating:"Führen Sie die Messung durch, indem Sie der Karte Punkte hinzufügen.",finishMeasurement:"Messung beenden",lastPoint:"Letzter Punkt",area:"Fläche",perimeter:"Rand",pointLocation:"Lage des Punkts",areaMeasurement:"Gemessene Fläche",linearMeasurement:"Gemessener Abstand",pathDistance:"Abstand entlang des Pfads",centerOnArea:"Auf diese Fläche zentrieren",centerOnLine:"Auf diesen Linienzug zentrieren",centerOnLocation:"Auf diesen Ort zentrieren",cancel:"Abbrechen",delete:"Löschen",acres:"Morgen",feet:"Fuß",kilometers:"Kilometer",hectares:"Hektar",meters:"Meter",miles:"Meilen",sqfeet:"Quadratfuß",sqmeters:"Quadratmeter",sqmiles:"Quadratmeilen",decPoint:",",thousandsSep:"."}},{}],29:[function(a,b,c){b.exports={measure:"Messung",measureDistancesAndAreas:"Abstände und Flächen messen",createNewMeasurement:"Eine neue Messung durchführen",startCreating:"Messen sie, indem Sie der Karte Punkte hinzufügen",finishMeasurement:"Messung beenden",lastPoint:"Letzter Punkt",area:"Fläche",perimeter:"Umfang",pointLocation:"Lage des Punkts",areaMeasurement:"Fläche",linearMeasurement:"Abstand",pathDistance:"Umfang",centerOnArea:"Auf diese Fläche zentrieren",centerOnLine:"Auf diese Linie zentrieren",centerOnLocation:"Auf diesen Ort zentrieren",cancel:"Abbrechen",delete:"Löschen",acres:"Morgen",feet:"Fuß",kilometers:"Kilometer",hectares:"Hektar",meters:"Meter",miles:"Meilen",sqfeet:"Quadratfuß",sqmeters:"Quadratmeter",sqmiles:"Quadratmeilen",decPoint:".",thousandsSep:"'"}},{}],30:[function(a,b,c){b.exports={measure:"Measure",measureDistancesAndAreas:"Measure distances and areas",createNewMeasurement:"Create a new measurement",startCreating:"Start creating a measurement by adding points to the map",finishMeasurement:"Finish measurement",lastPoint:"Last point",area:"Area",perimeter:"Perimeter",pointLocation:"Point location",areaMeasurement:"Area measurement",linearMeasurement:"Linear measurement",pathDistance:"Path distance",centerOnArea:"Center on this area",centerOnLine:"Center on this line",centerOnLocation:"Center on this location",cancel:"Cancel",delete:"Delete",acres:"Acres",feet:"Feet",kilometers:"Kilometers",hectares:"Hectares",meters:"Meters",miles:"Miles",sqfeet:"Sq Feet",sqmeters:"Sq Meters",sqmiles:"Sq Miles",decPoint:".",thousandsSep:","}},{}],31:[function(a,b,c){b.exports={measure:"Measure",measureDistancesAndAreas:"Measure distances and areas",createNewMeasurement:"Create a new measurement",startCreating:"Start creating a measurement by adding points to the map",finishMeasurement:"Finish measurement",lastPoint:"Last point",area:"Area",perimeter:"Perimeter",pointLocation:"Point location",areaMeasurement:"Area measurement",linearMeasurement:"Linear measurement",pathDistance:"Path distance",centerOnArea:"Centre on this area",centerOnLine:"Centre on this line",centerOnLocation:"Centre on this location",cancel:"Cancel",delete:"Delete",acres:"Acres",feet:"Feet",kilometers:"Kilometres",hectares:"Hectares",meters:"Meters",miles:"Miles",sqfeet:"Sq Feet",sqmeters:"Sq Meters",sqmiles:"Sq Miles",decPoint:".",thousandsSep:","}},{}],32:[function(a,b,c){b.exports={measure:"Medición",measureDistancesAndAreas:"Mida distancias y áreas",createNewMeasurement:"Crear nueva medición",startCreating:"Empiece a crear la medición añadiendo puntos al mapa",finishMeasurement:"Terminar medición",lastPoint:"Último punto",area:"Área",perimeter:"Perímetro",pointLocation:"Localización del punto",areaMeasurement:"Medición de área",linearMeasurement:"Medición linear",pathDistance:"Distancia de ruta",centerOnArea:"Centrar en este área",centerOnLine:"Centrar en esta línea",centerOnLocation:"Centrar en esta localización",cancel:"Cancelar",delete:"Eliminar",acres:"Acres",feet:"Pies",kilometers:"Kilómetros",hectares:"Hectáreas",meters:"Metros",miles:"Millas",sqfeet:"Pies cuadrados",sqmeters:"Metros cuadrados",sqmiles:"Millas cuadradas",decPoint:".",thousandsSep:" "}},{}],33:[function(a,b,c){b.exports={measure:"اندازه گیری",measureDistancesAndAreas:"اندازه گیری فاصله و مساحت",createNewMeasurement:"ثبت اندازه گیری جدید",startCreating:"برای ثبت اندازه گیری جدید نقاطی را به نقشه اضافه کنید.",finishMeasurement:"پایان اندازه گیری",lastPoint:"آخرین نقطه",area:"مساحت",perimeter:"محیط",pointLocation:"مکان نقطه",areaMeasurement:"اندازه گیری مساحت",linearMeasurement:"اندازه گیری خطی",pathDistance:"فاصله مسیر",centerOnArea:"مرکز این سطح",centerOnLine:"مرکز این خط",centerOnLocation:"مرکز این مکان",cancel:"لغو",delete:"حذف",acres:"ایکر",feet:"پا",kilometers:"کیلومتر",hectares:"هکتار",meters:"متر",miles:"مایل",sqfeet:"پا مربع",sqmeters:"متر مربع",sqmiles:"مایل مربع",decPoint:"/",thousandsSep:","}},{}],34:[function(a,b,c){b.exports={measure:"Sukat",measureDistancesAndAreas:"Kalkulahin ang tamang distansya at sukat",createNewMeasurement:"Lumikha ng isang bagong pagsukat",startCreating:"Simulan ang paglikha ng isang pagsukat sa pamamagitan ng pagdaragdag ng mga puntos sa mapa",finishMeasurement:"Tapusin ang pagsukat",lastPoint:"Huling punto sa mapa",area:"Sukat",perimeter:"Palibot",pointLocation:"Lokasyon ng punto",areaMeasurement:"Kabuuang sukat",linearMeasurement:"Pagsukat ng guhit",pathDistance:"Distansya ng daanan",centerOnArea:"I-sentro sa lugar na ito",centerOnLine:"I-sentro sa linya na ito",centerOnLocation:"I-sentro sa lokasyong ito",cancel:"Kanselahin",delete:"Tanggalin",acres:"Acres",feet:"Talampakan",kilometers:"Kilometro",hectares:"Hektarya",meters:"Metro",miles:"Milya",sqfeet:"Talampakang Kwadrado",sqmeters:"Metro Kwadrado",sqmiles:"Milya Kwadrado",decPoint:".",thousandsSep:","}},{}],35:[function(a,b,c){b.exports={measure:"Mesure",measureDistancesAndAreas:"Mesurer les distances et superficies",createNewMeasurement:"Créer une nouvelle mesure",startCreating:"Débuter la création d'une nouvelle mesure en ajoutant des points sur la carte",finishMeasurement:"Finir la mesure",lastPoint:"Dernier point",area:"Superficie",perimeter:"Périmètre",pointLocation:"Placement du point",areaMeasurement:"Mesure de superficie",linearMeasurement:"Mesure linéaire",pathDistance:"Distance du chemin",centerOnArea:"Centrer sur cette zone",centerOnLine:"Centrer sur cette ligne",centerOnLocation:"Centrer à cet endroit",cancel:"Annuler",delete:"Supprimer",acres:"Acres",feet:"Pieds",kilometers:"Kilomètres",hectares:"Hectares",meters:"Mètres",miles:"Miles",sqfeet:"Pieds carrés",sqmeters:"Mètres carrés",sqmiles:"Miles carrés",decPoint:",",thousandsSep:" "}},{}],36:[function(a,b,c){b.exports={measure:"Misura",measureDistancesAndAreas:"Misura distanze e aree",createNewMeasurement:"Crea una nuova misurazione",startCreating:"Comincia a creare una misurazione aggiungendo punti alla mappa",finishMeasurement:"Misurazione conclusa",lastPoint:"Ultimo punto",area:"Area",perimeter:"Perimetro",pointLocation:"Posizione punto",areaMeasurement:"Misura area",linearMeasurement:"Misura lineare",pathDistance:"Distanza percorso",centerOnArea:"Centra su questa area",centerOnLine:"Centra su questa linea",centerOnLocation:"Centra su questa posizione",cancel:"Annulla",delete:"Cancella",acres:"Acri",feet:"Piedi",kilometers:"Chilometri",hectares:"Ettari",meters:"Metri",miles:"Miglia",sqfeet:"Piedi quadri",sqmeters:"Metri quadri",sqmiles:"Miglia quadre",decPoint:".",thousandsSep:","}},{}],37:[function(a,b,c){b.exports={measure:"Meet",measureDistancesAndAreas:"Meet afstanden en oppervlakten",createNewMeasurement:"Maak een nieuwe meting",startCreating:"Begin een meting door punten toe te voegen aan de kaart",finishMeasurement:"Beëindig meting",lastPoint:"Laatste punt",area:"Oppervlakte",perimeter:"Omtrek",pointLocation:"Locatie punt",areaMeasurement:"Oppervlakte meting",linearMeasurement:"Gemeten afstand",pathDistance:"Afstand over de lijn",centerOnArea:"Centreer op dit gebied",centerOnLine:"Centreer op deze lijn",centerOnLocation:"Centreer op deze locatie",cancel:"Annuleer",delete:"Wis",acres:"are",feet:"Voet",kilometers:"km",hectares:"ha",meters:"m",miles:"Mijl",sqfeet:"Vierkante Feet",sqmeters:"m2",sqmiles:"Vierkante Mijl",decPoint:",",thousandsSep:"."}},{}],38:[function(a,b,c){b.exports={measure:"Pomiar",measureDistancesAndAreas:"Pomiar odległości i powierzchni",createNewMeasurement:"Utwórz nowy pomiar",startCreating:"Rozpocznij tworzenie nowego pomiaru poprzez dodanie punktów na mapie",finishMeasurement:"Zakończ pomiar",lastPoint:"Ostatni punkt",area:"Powierzchnia",perimeter:"Obwód",pointLocation:"Punkt lokalizacji",areaMeasurement:"Pomiar powierzchni",linearMeasurement:"Pomiar liniowy",pathDistance:"Długość ścieżki",centerOnArea:"Środek tego obszaru",centerOnLine:"Środek tej linii",centerOnLocation:"Środek w tej lokalizacji",cancel:"Anuluj",delete:"Skasuj",acres:"akrów",feet:"stóp",kilometers:"kilometrów",hectares:"hektarów",meters:"metrów",miles:"mil",sqfeet:"stóp kwadratowych",sqmeters:"metrów kwadratowych",sqmiles:"mil kwadratowych",decPoint:",",thousandsSep:"."}},{}],39:[function(a,b,c){b.exports={measure:"Medidas",measureDistancesAndAreas:"Mede distâncias e áreas",createNewMeasurement:"Criar nova medida",startCreating:"Comece criando uma medida, adicionando pontos no mapa",finishMeasurement:"Finalizar medida",lastPoint:"Último ponto",area:"Área",perimeter:"Perímetro",pointLocation:"Localização do ponto",areaMeasurement:"Medida de área",linearMeasurement:"Medida linear",pathDistance:"Distância",centerOnArea:"Centralizar nesta área",centerOnLine:"Centralizar nesta linha",centerOnLocation:"Centralizar nesta localização",cancel:"Cancelar",delete:"Excluir",acres:"Acres",feet:"Pés",kilometers:"Quilômetros",hectares:"Hectares",meters:"Metros",miles:"Milhas",sqfeet:"Pés²",sqmeters:"Metros²",sqmiles:"Milhas²",decPoint:",",thousandsSep:"."}},{}],40:[function(a,b,c){b.exports={measure:"Medições",measureDistancesAndAreas:"Medir distâncias e áreas",createNewMeasurement:"Criar uma nova medição",startCreating:"Adicione pontos no mapa, para criar uma nova medição",finishMeasurement:"Finalizar medição",lastPoint:"Último ponto",area:"Área",perimeter:"Perímetro",pointLocation:"Localização do ponto",areaMeasurement:"Medição da área",linearMeasurement:"Medição linear",pathDistance:"Distância",centerOnArea:"Centrar nesta área",centerOnLine:"Centrar nesta linha",centerOnLocation:"Centrar nesta localização",cancel:"Cancelar",delete:"Eliminar",acres:"Acres",feet:"Pés",kilometers:"Kilômetros",hectares:"Hectares",meters:"Metros",miles:"Milhas",sqfeet:"Pés²",sqmeters:"Metros²",sqmiles:"Milhas²",decPoint:",",thousandsSep:"."}},{}],41:[function(a,b,c){b.exports={measure:"Измерение",measureDistancesAndAreas:"Измерение расстояний и площади",createNewMeasurement:"Создать новое измерение",startCreating:"Для начала измерения добавьте точку на карту",finishMeasurement:"Закончить измерение",lastPoint:"Последняя точка",area:"Область",perimeter:"Периметр",pointLocation:"Местоположение точки",areaMeasurement:"Измерение области",linearMeasurement:"Линейное измерение",pathDistance:"Расстояние",centerOnArea:"Сфокусироваться на данной области",centerOnLine:"Сфокусироваться на данной линии",centerOnLocation:"Сфокусироваться на данной местности",cancel:"Отменить",delete:"Удалить",acres:"акры",feet:"фут",kilometers:"км",hectares:"га",meters:"м",miles:"миль",sqfeet:"футов²",sqmeters:"м²",sqmiles:"миль²",decPoint:".",thousandsSep:","}},{}],42:[function(a,b,c){b.exports={measure:"Hesapla",measureDistancesAndAreas:"Uzaklık ve alan hesapla",createNewMeasurement:"Yeni hesaplama",startCreating:"Yeni nokta ekleyerek hesaplamaya başla",finishMeasurement:"Hesaplamayı bitir",lastPoint:"Son nokta",area:"Alan",perimeter:"Çevre uzunluğu",pointLocation:"Nokta yeri",areaMeasurement:"Alan hesaplaması",linearMeasurement:"Doğrusal hesaplama",pathDistance:"Yol uzunluğu",centerOnArea:"Bu alana odaklan",centerOnLine:"Bu doğtuya odaklan",centerOnLocation:"Bu yere odaklan",cancel:"Çıkış",delete:"Sil",acres:"Dönüm",feet:"Feet",kilometers:"Kilometre",hectares:"Hektar",meters:"Metre",miles:"Mil",sqfeet:"Feet kare",sqmeters:"Metre kare",sqmiles:"Mil kare",decPoint:".",thousandsSep:","}},{}],43:[function(a,b,c){(function(b){var c=a("underscore"),d="undefined"!=typeof window?window.L:"undefined"!=typeof b?b.L:null,e=a("humanize"),f=a("./units"),g=a("./calc"),h=a("./dom"),i=h.$,j=a("./mapsymbology"),k=c.template('<%= i18n.__(\'measure\') %>\n
\n
\n

<%= i18n.__(\'measureDistancesAndAreas\') %>

\n \n
\n
\n

<%= i18n.__(\'measureDistancesAndAreas\') %>

\n

<%= i18n.__(\'startCreating\') %>

\n
\n \n
\n
'),l=c.template('
\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
\n<% if (model.pointCount > 1) { %>\n
\n

<%= i18n.__(\'pathDistance\') %> <%= model.lengthDisplay %>

\n
\n<% } %>\n<% if (model.pointCount > 2) { %>\n
\n

<%= i18n.__(\'area\') %> <%= model.areaDisplay %>

\n
\n<% } %>'),m=c.template('

<%= i18n.__(\'pointLocation\') %>

\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('

<%= i18n.__(\'linearMeasurement\') %>

\n

<%= model.lengthDisplay %>

\n'),o=c.template('

<%= i18n.__(\'areaMeasurement\') %>

\n

<%= 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);gb?(g&&(clearTimeout(g),g=null),h=j,f=a.apply(d,e),g||(d=e=null)):g||c.trailing===!1||(g=setTimeout(i,k)),f}},u.debounce=function(a,b,c){var d,e,f,g,h,i=function(){var j=u.now()-g;j=0?d=setTimeout(i,b-j):(d=null,c||(h=a.apply(f,e),d||(f=e=null)))};return function(){f=this,e=arguments,g=u.now();var j=c&&!d;return d||(d=setTimeout(i,b)),j&&(h=a.apply(f,e),f=e=null),h}},u.wrap=function(a,b){return u.partial(b,a)},u.negate=function(a){return function(){return!a.apply(this,arguments)}},u.compose=function(){var a=arguments,b=a.length-1;return function(){for(var c=b,d=a[b].apply(this,arguments);c--;)d=a[c].call(this,d);return d}},u.after=function(a,b){return function(){if(--a<1)return b.apply(this,arguments)}},u.before=function(a,b){var c;return function(){return--a>0&&(c=b.apply(this,arguments)),a<=1&&(b=null),c}},u.once=u.partial(u.before,2);var G=!{toString:null}.propertyIsEnumerable("toString"),H=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];u.keys=function(a){if(!u.isObject(a))return[];if(q)return q(a);var b=[];for(var c in a)u.has(a,c)&&b.push(c);return G&&f(a,b),b},u.allKeys=function(a){if(!u.isObject(a))return[];var b=[];for(var c in a)b.push(c);return G&&f(a,b),b},u.values=function(a){for(var b=u.keys(a),c=b.length,d=Array(c),e=0;e":">",'"':""","'":"'","`":"`"},K=u.invert(J),L=function(a){var b=function(b){return a[b]},c="(?:"+u.keys(a).join("|")+")",d=RegExp(c),e=RegExp(c,"g");return function(a){return a=null==a?"":""+a,d.test(a)?a.replace(e,b):a}};u.escape=L(J),u.unescape=L(K),u.result=function(a,b,c){var d=null==a?void 0:a[b];return void 0===d&&(d=c),u.isFunction(d)?d.call(a):d};var M=0;u.uniqueId=function(a){var b=++M+"";return a?a+b:b},u.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var N=/(.)^/,O={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},P=/\\|'|\r|\n|\u2028|\u2029/g,Q=function(a){return"\\"+O[a]};u.template=function(a,b,c){!b&&c&&(b=c),b=u.defaults({},b,u.templateSettings);var d=RegExp([(b.escape||N).source,(b.interpolate||N).source,(b.evaluate||N).source].join("|")+"|$","g"),e=0,f="__p+='";a.replace(d,function(b,c,d,g,h){return f+=a.slice(e,h).replace(P,Q),e=h+b.length,c?f+="'+\n((__t=("+c+"))==null?'':_.escape(__t))+\n'":d?f+="'+\n((__t=("+d+"))==null?'':__t)+\n'":g&&(f+="';\n"+g+"\n__p+='"),b}),f+="';\n",b.variable||(f="with(obj||{}){\n"+f+"}\n"),f="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+f+"return __p;\n";try{var g=new Function(b.variable||"obj","_",f)}catch(a){throw a.source=f,a}var h=function(a){return g.call(this,a,u)},i=b.variable||"obj";return h.source="function("+i+"){\n"+f+"}",h},u.chain=function(a){var b=u(a);return b._chain=!0,b};var R=function(a,b){return a._chain?u(b).chain():b};u.mixin=function(a){u.each(u.functions(a),function(b){var c=u[b]=a[b];u.prototype[b]=function(){var a=[this._wrapped];return l.apply(a,arguments),R(this,c.apply(u,a))}})},u.mixin(u),u.each(["pop","push","reverse","shift","sort","splice","unshift"],function(a){var b=i[a];u.prototype[a]=function(){var c=this._wrapped;return b.apply(c,arguments),"shift"!==a&&"splice"!==a||0!==c.length||delete c[0],R(this,c)}}),u.each(["concat","join","slice"],function(a){var b=i[a];u.prototype[a]=function(){return R(this,b.apply(this._wrapped,arguments))}}),u.prototype.value=function(){return this._wrapped},u.prototype.valueOf=u.prototype.toJSON=u.prototype.value,u.prototype.toString=function(){return""+this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return u})}).call(this)},{}],23:[function(a,b,c){var d=a("underscore"),e=a("geocrunch"),f=function(a){return a<10?"0"+a.toString():a.toString()},g=function(a,b,c){var d=Math.abs(a),e=Math.floor(d),g=Math.floor(60*(d-e)),h=Math.round(3600*(d-e-g/60)*100)/100,i=d===a?b:c;return f(e)+"° "+f(g)+"' "+f(h)+'" '+i},h=function(a){var b=d.last(a),c=e.path(d.map(a,function(a){return[a.lng,a.lat]})),f=c.distance({units:"meters"}),h=c.area({units:"sqmeters"});return{lastCoord:{dd:{x:b.lng,y:b.lat},dms:{x:g(b.lng,"E","W"),y:g(b.lat,"N","S")}},length:f,area:h}};b.exports={measure:h}},{geocrunch:7,underscore:22}],24:[function(a,b,c){var d=function(a,b){return b||(b=document),b.querySelector(a)},e=function(a,b){return b||(b=document),Array.prototype.slice.call(b.querySelectorAll(a))},f=function(a){if(a)return a.setAttribute("style","display:none;"),a},g=function(a){if(a)return a.removeAttribute("style"),a};b.exports={$:d,$$:e,hide:f,show:g}},{}],25:[function(a,b,c){b.exports={measure:"Medir",measureDistancesAndAreas:"Medeix distancies i àreas",createNewMeasurement:"Crear nova medicio",startCreating:"Començi a crear la medicio afegint punts al mapa",finishMeasurement:"Acabar la medició",lastPoint:"Últim punt",area:"Área",perimeter:"Perómetre",pointLocation:"Localizació del punt",areaMeasurement:"Medició d'área",linearMeasurement:"Medició lineal",pathDistance:"Distancia de ruta",centerOnArea:"Centrar en aquesta área",centerOnLine:"Centrar en aquesta línia",centerOnLocation:"Centrar en aquesta localizació",cancel:"Cancel·lar",delete:"Eliminar",acres:"Acres",feet:"Peus",kilometers:"Quilòmetres",hectares:"Hectàreas",meters:"Metros",miles:"Milles",sqfeet:"Peus cuadrats",sqmeters:"Metres cuadrats",sqmiles:"Milles cuadrades",decPoint:".",thousandsSep:" "}},{}],26:[function(a,b,c){b.exports={measure:"测量",measureDistancesAndAreas:"同时测量距离和面积",createNewMeasurement:"开始一次新的测量",startCreating:"点击地图加点以开始创建测量",finishMeasurement:"完成测量",lastPoint:"最后点的坐标",area:"面积",perimeter:"周长",pointLocation:"点的坐标",areaMeasurement:"面积测量",linearMeasurement:"距离测量",pathDistance:"路径长度",centerOnArea:"该面积居中",centerOnLine:"该线段居中",centerOnLocation:"该位置居中",cancel:"取消",delete:"删除",acres:"公亩",feet:"英尺",kilometers:"公里",hectares:"公顷",meters:"米",miles:"英里",sqfeet:"平方英尺",sqmeters:"平方米",sqmiles:"平方英里",decPoint:".",thousandsSep:","}},{}],27:[function(a,b,c){b.exports={measure:"Mål",measureDistancesAndAreas:"Mål afstande og arealer",createNewMeasurement:"Lav en ny måling",startCreating:"Begynd målingen ved at tilføje punkter på kortet",finishMeasurement:"Afslut måling",lastPoint:"Sidste punkt",area:"Areal",perimeter:"Omkreds",pointLocation:"Punkt",areaMeasurement:"Areal",linearMeasurement:"Linje",pathDistance:"Sti afstand",centerOnArea:"Centrér dette område",centerOnLine:"Centrér denne linje",centerOnLocation:"Centrér dette punkt",cancel:"Annuller",delete:"Slet",acres:"acre",feet:"fod",kilometers:"km",hectares:"ha",meters:"m",miles:"mil",sqfeet:"kvadratfod",sqmeters:"m²",sqmiles:"kvadratmil",decPoint:",",thousandsSep:"."}},{}],28:[function(a,b,c){b.exports={measure:"Messung",measureDistancesAndAreas:"Messung von Abständen und Flächen",createNewMeasurement:"Eine neue Messung durchführen",startCreating:"Führen Sie die Messung durch, indem Sie der Karte Punkte hinzufügen.",finishMeasurement:"Messung beenden",lastPoint:"Letzter Punkt",area:"Fläche",perimeter:"Rand",pointLocation:"Lage des Punkts",areaMeasurement:"Gemessene Fläche",linearMeasurement:"Gemessener Abstand",pathDistance:"Abstand entlang des Pfads",centerOnArea:"Auf diese Fläche zentrieren",centerOnLine:"Auf diesen Linienzug zentrieren",centerOnLocation:"Auf diesen Ort zentrieren",cancel:"Abbrechen",delete:"Löschen",acres:"Morgen",feet:"Fuß",kilometers:"Kilometer",hectares:"Hektar",meters:"Meter",miles:"Meilen",sqfeet:"Quadratfuß",sqmeters:"Quadratmeter",sqmiles:"Quadratmeilen",decPoint:",",thousandsSep:"."}},{}],29:[function(a,b,c){b.exports={measure:"Messung",measureDistancesAndAreas:"Abstände und Flächen messen",createNewMeasurement:"Eine neue Messung durchführen",startCreating:"Messen sie, indem Sie der Karte Punkte hinzufügen",finishMeasurement:"Messung beenden",lastPoint:"Letzter Punkt",area:"Fläche",perimeter:"Umfang",pointLocation:"Lage des Punkts",areaMeasurement:"Fläche",linearMeasurement:"Abstand",pathDistance:"Umfang",centerOnArea:"Auf diese Fläche zentrieren",centerOnLine:"Auf diese Linie zentrieren",centerOnLocation:"Auf diesen Ort zentrieren",cancel:"Abbrechen",delete:"Löschen",acres:"Morgen",feet:"Fuß",kilometers:"Kilometer",hectares:"Hektar",meters:"Meter",miles:"Meilen",sqfeet:"Quadratfuß",sqmeters:"Quadratmeter",sqmiles:"Quadratmeilen",decPoint:".",thousandsSep:"'"}},{}],30:[function(a,b,c){b.exports={measure:"Measure",measureDistancesAndAreas:"Measure distances and areas",createNewMeasurement:"Create a new measurement",startCreating:"Start creating a measurement by adding points to the map",finishMeasurement:"Finish measurement",lastPoint:"Last point",area:"Area",perimeter:"Perimeter",pointLocation:"Point location",areaMeasurement:"Area measurement",linearMeasurement:"Linear measurement",pathDistance:"Path distance",centerOnArea:"Center on this area",centerOnLine:"Center on this line",centerOnLocation:"Center on this location",cancel:"Cancel",delete:"Delete",acres:"Acres",feet:"Feet",kilometers:"Kilometers",hectares:"Hectares",meters:"Meters",miles:"Miles",sqfeet:"Sq Feet",sqmeters:"Sq Meters",sqmiles:"Sq Miles",decPoint:".",thousandsSep:","}},{}],31:[function(a,b,c){b.exports={measure:"Measure",measureDistancesAndAreas:"Measure distances and areas",createNewMeasurement:"Create a new measurement",startCreating:"Start creating a measurement by adding points to the map",finishMeasurement:"Finish measurement",lastPoint:"Last point",area:"Area",perimeter:"Perimeter",pointLocation:"Point location",areaMeasurement:"Area measurement",linearMeasurement:"Linear measurement",pathDistance:"Path distance",centerOnArea:"Centre on this area",centerOnLine:"Centre on this line",centerOnLocation:"Centre on this location",cancel:"Cancel",delete:"Delete",acres:"Acres",feet:"Feet",kilometers:"Kilometres",hectares:"Hectares",meters:"Meters",miles:"Miles",sqfeet:"Sq Feet",sqmeters:"Sq Meters",sqmiles:"Sq Miles",decPoint:".",thousandsSep:","}},{}],32:[function(a,b,c){b.exports={measure:"Medición",measureDistancesAndAreas:"Mida distancias y áreas",createNewMeasurement:"Crear nueva medición",startCreating:"Empiece a crear la medición añadiendo puntos al mapa",finishMeasurement:"Terminar medición",lastPoint:"Último punto",area:"Área",perimeter:"Perímetro",pointLocation:"Localización del punto",areaMeasurement:"Medición de área",linearMeasurement:"Medición linear",pathDistance:"Distancia de ruta",centerOnArea:"Centrar en este área",centerOnLine:"Centrar en esta línea",centerOnLocation:"Centrar en esta localización",cancel:"Cancelar",delete:"Eliminar",acres:"Acres",feet:"Pies",kilometers:"Kilómetros",hectares:"Hectáreas",meters:"Metros",miles:"Millas",sqfeet:"Pies cuadrados",sqmeters:"Metros cuadrados",sqmiles:"Millas cuadradas",decPoint:".",thousandsSep:" "}},{}],33:[function(a,b,c){b.exports={measure:"اندازه گیری",measureDistancesAndAreas:"اندازه گیری فاصله و مساحت",createNewMeasurement:"ثبت اندازه گیری جدید",startCreating:"برای ثبت اندازه گیری جدید نقاطی را به نقشه اضافه کنید.",finishMeasurement:"پایان اندازه گیری",lastPoint:"آخرین نقطه",area:"مساحت",perimeter:"محیط",pointLocation:"مکان نقطه",areaMeasurement:"اندازه گیری مساحت",linearMeasurement:"اندازه گیری خطی",pathDistance:"فاصله مسیر",centerOnArea:"مرکز این سطح",centerOnLine:"مرکز این خط",centerOnLocation:"مرکز این مکان",cancel:"لغو",delete:"حذف",acres:"ایکر",feet:"پا",kilometers:"کیلومتر",hectares:"هکتار",meters:"متر",miles:"مایل",sqfeet:"پا مربع",sqmeters:"متر مربع",sqmiles:"مایل مربع",decPoint:"/",thousandsSep:","}},{}],34:[function(a,b,c){b.exports={measure:"Sukat",measureDistancesAndAreas:"Kalkulahin ang tamang distansya at sukat",createNewMeasurement:"Lumikha ng isang bagong pagsukat",startCreating:"Simulan ang paglikha ng isang pagsukat sa pamamagitan ng pagdaragdag ng mga puntos sa mapa",finishMeasurement:"Tapusin ang pagsukat",lastPoint:"Huling punto sa mapa",area:"Sukat",perimeter:"Palibot",pointLocation:"Lokasyon ng punto",areaMeasurement:"Kabuuang sukat",linearMeasurement:"Pagsukat ng guhit",pathDistance:"Distansya ng daanan",centerOnArea:"I-sentro sa lugar na ito",centerOnLine:"I-sentro sa linya na ito",centerOnLocation:"I-sentro sa lokasyong ito",cancel:"Kanselahin",delete:"Tanggalin",acres:"Acres",feet:"Talampakan",kilometers:"Kilometro",hectares:"Hektarya",meters:"Metro",miles:"Milya",sqfeet:"Talampakang Kwadrado",sqmeters:"Metro Kwadrado",sqmiles:"Milya Kwadrado",decPoint:".",thousandsSep:","}},{}],35:[function(a,b,c){b.exports={measure:"Mesure",measureDistancesAndAreas:"Mesurer les distances et superficies",createNewMeasurement:"Créer une nouvelle mesure",startCreating:"Débuter la création d'une nouvelle mesure en ajoutant des points sur la carte",finishMeasurement:"Finir la mesure",lastPoint:"Dernier point",area:"Superficie",perimeter:"Périmètre",pointLocation:"Placement du point",areaMeasurement:"Mesure de superficie",linearMeasurement:"Mesure linéaire",pathDistance:"Distance du chemin",centerOnArea:"Centrer sur cette zone",centerOnLine:"Centrer sur cette ligne",centerOnLocation:"Centrer à cet endroit",cancel:"Annuler",delete:"Supprimer",acres:"Acres",feet:"Pieds",kilometers:"Kilomètres",hectares:"Hectares",meters:"Mètres",miles:"Miles",sqfeet:"Pieds carrés",sqmeters:"Mètres carrés",sqmiles:"Miles carrés",decPoint:",",thousandsSep:" "}},{}],36:[function(a,b,c){b.exports={measure:"Misura",measureDistancesAndAreas:"Misura distanze e aree",createNewMeasurement:"Crea una nuova misurazione",startCreating:"Comincia a creare una misurazione aggiungendo punti alla mappa",finishMeasurement:"Misurazione conclusa",lastPoint:"Ultimo punto",area:"Area",perimeter:"Perimetro",pointLocation:"Posizione punto",areaMeasurement:"Misura area",linearMeasurement:"Misura lineare",pathDistance:"Distanza percorso",centerOnArea:"Centra su questa area",centerOnLine:"Centra su questa linea",centerOnLocation:"Centra su questa posizione",cancel:"Annulla",delete:"Cancella",acres:"Acri",feet:"Piedi",kilometers:"Chilometri",hectares:"Ettari",meters:"Metri",miles:"Miglia",sqfeet:"Piedi quadri",sqmeters:"Metri quadri",sqmiles:"Miglia quadre",decPoint:".",thousandsSep:","}},{}],37:[function(a,b,c){b.exports={measure:"Meet",measureDistancesAndAreas:"Meet afstanden en oppervlakten",createNewMeasurement:"Maak een nieuwe meting",startCreating:"Begin een meting door punten toe te voegen aan de kaart",finishMeasurement:"Beëindig meting",lastPoint:"Laatste punt",area:"Oppervlakte",perimeter:"Omtrek",pointLocation:"Locatie punt",areaMeasurement:"Oppervlakte meting",linearMeasurement:"Gemeten afstand",pathDistance:"Afstand over de lijn",centerOnArea:"Centreer op dit gebied",centerOnLine:"Centreer op deze lijn",centerOnLocation:"Centreer op deze locatie",cancel:"Annuleer",delete:"Wis",acres:"are",feet:"Voet",kilometers:"km",hectares:"ha",meters:"m",miles:"Mijl",sqfeet:"Vierkante Feet",sqmeters:"m2",sqmiles:"Vierkante Mijl",decPoint:",",thousandsSep:"."}},{}],38:[function(a,b,c){b.exports={measure:"Pomiar",measureDistancesAndAreas:"Pomiar odległości i powierzchni",createNewMeasurement:"Utwórz nowy pomiar",startCreating:"Rozpocznij tworzenie nowego pomiaru poprzez dodanie punktów na mapie",finishMeasurement:"Zakończ pomiar",lastPoint:"Ostatni punkt",area:"Powierzchnia",perimeter:"Obwód",pointLocation:"Punkt lokalizacji",areaMeasurement:"Pomiar powierzchni",linearMeasurement:"Pomiar liniowy",pathDistance:"Długość ścieżki",centerOnArea:"Środek tego obszaru",centerOnLine:"Środek tej linii",centerOnLocation:"Środek w tej lokalizacji",cancel:"Anuluj",delete:"Skasuj",acres:"akrów",feet:"stóp",kilometers:"kilometrów",hectares:"hektarów",meters:"metrów",miles:"mil",sqfeet:"stóp kwadratowych",sqmeters:"metrów kwadratowych",sqmiles:"mil kwadratowych",decPoint:",",thousandsSep:"."}},{}],39:[function(a,b,c){b.exports={measure:"Medidas",measureDistancesAndAreas:"Mede distâncias e áreas",createNewMeasurement:"Criar nova medida",startCreating:"Comece criando uma medida, adicionando pontos no mapa",finishMeasurement:"Finalizar medida",lastPoint:"Último ponto",area:"Área",perimeter:"Perímetro",pointLocation:"Localização do ponto",areaMeasurement:"Medida de área",linearMeasurement:"Medida linear",pathDistance:"Distância",centerOnArea:"Centralizar nesta área",centerOnLine:"Centralizar nesta linha",centerOnLocation:"Centralizar nesta localização",cancel:"Cancelar",delete:"Excluir",acres:"Acres",feet:"Pés",kilometers:"Quilômetros",hectares:"Hectares",meters:"Metros",miles:"Milhas",sqfeet:"Pés²",sqmeters:"Metros²",sqmiles:"Milhas²",decPoint:",",thousandsSep:"."}},{}],40:[function(a,b,c){b.exports={measure:"Medições",measureDistancesAndAreas:"Medir distâncias e áreas",createNewMeasurement:"Criar uma nova medição",startCreating:"Adicione pontos no mapa, para criar uma nova medição",finishMeasurement:"Finalizar medição",lastPoint:"Último ponto",area:"Área",perimeter:"Perímetro",pointLocation:"Localização do ponto",areaMeasurement:"Medição da área",linearMeasurement:"Medição linear",pathDistance:"Distância",centerOnArea:"Centrar nesta área",centerOnLine:"Centrar nesta linha",centerOnLocation:"Centrar nesta localização",cancel:"Cancelar",delete:"Eliminar",acres:"Acres",feet:"Pés",kilometers:"Kilômetros",hectares:"Hectares",meters:"Metros",miles:"Milhas",sqfeet:"Pés²",sqmeters:"Metros²",sqmiles:"Milhas²",decPoint:",",thousandsSep:"."}},{}],41:[function(a,b,c){b.exports={measure:"Измерение",measureDistancesAndAreas:"Измерение расстояний и площади",createNewMeasurement:"Создать новое измерение",startCreating:"Для начала измерения добавьте точку на карту",finishMeasurement:"Закончить измерение",lastPoint:"Последняя точка",area:"Область",perimeter:"Периметр",pointLocation:"Местоположение точки",areaMeasurement:"Измерение области",linearMeasurement:"Линейное измерение",pathDistance:"Расстояние",centerOnArea:"Сфокусироваться на данной области",centerOnLine:"Сфокусироваться на данной линии",centerOnLocation:"Сфокусироваться на данной местности",cancel:"Отменить",delete:"Удалить",acres:"акры",feet:"фут",kilometers:"км",hectares:"га",meters:"м",miles:"миль",sqfeet:"футов²",sqmeters:"м²",sqmiles:"миль²",decPoint:".",thousandsSep:","}},{}],42:[function(a,b,c){b.exports={measure:"Mäta",measureDistancesAndAreas:"Mäta avstånd och yta",createNewMeasurement:"Skapa ny mätning",startCreating:"Börja mätning genom att lägga till punkter på kartan",finishMeasurement:"Avsluta mätning",lastPoint:"Sista punkt",area:"Yta",perimeter:"Omkrets",pointLocation:"Punktens Läge",areaMeasurement:"Arealmätning",linearMeasurement:"Längdmätning",pathDistance:"Total linjelängd",centerOnArea:"Centrera på detta område",centerOnLine:"Centrera på denna linje",centerOnLocation:"Centrera på denna punkt",cancel:"Avbryt",delete:"Radera",acres:"Tunnland",feet:"Fot",kilometers:"Kilometer",hectares:"Hektar",meters:"Meter",miles:"Miles",sqfeet:"Kvadratfot",sqmeters:"Kvadratmeter",sqmiles:"Kvadratmiles",decPoint:",",thousandsSep:" "}},{}],43:[function(a,b,c){b.exports={measure:"Hesapla",measureDistancesAndAreas:"Uzaklık ve alan hesapla",createNewMeasurement:"Yeni hesaplama",startCreating:"Yeni nokta ekleyerek hesaplamaya başla",finishMeasurement:"Hesaplamayı bitir",lastPoint:"Son nokta",area:"Alan",perimeter:"Çevre uzunluğu",pointLocation:"Nokta yeri",areaMeasurement:"Alan hesaplaması",linearMeasurement:"Doğrusal hesaplama",pathDistance:"Yol uzunluğu",centerOnArea:"Bu alana odaklan",centerOnLine:"Bu doğtuya odaklan",centerOnLocation:"Bu yere odaklan",cancel:"Çıkış",delete:"Sil",acres:"Dönüm",feet:"Feet",kilometers:"Kilometre",hectares:"Hektar",meters:"Metre",miles:"Mil",sqfeet:"Feet kare",sqmeters:"Metre kare",sqmiles:"Mil kare",decPoint:".",thousandsSep:","}},{}],44:[function(a,b,c){(function(b){var c=a("underscore"),d="undefined"!=typeof window?window.L:"undefined"!=typeof b?b.L:null,e=a("humanize"),f=a("./units"),g=a("./calc"),h=a("./dom"),i=h.$,j=a("./mapsymbology"),k=c.template('<%= i18n.__(\'measure\') %>\n
\n
\n

<%= i18n.__(\'measureDistancesAndAreas\') %>

\n \n
\n
\n

<%= i18n.__(\'measureDistancesAndAreas\') %>

\n

<%= i18n.__(\'startCreating\') %>

\n
\n \n
\n
'),l=c.template('
\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
\n<% if (model.pointCount > 1) { %>\n
\n

<%= i18n.__(\'pathDistance\') %> <%= model.lengthDisplay %>

\n
\n<% } %>\n<% if (model.pointCount > 2) { %>\n
\n

<%= i18n.__(\'area\') %> <%= model.areaDisplay %>

\n
\n<% } %>'),m=c.template('

<%= i18n.__(\'pointLocation\') %>

\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('

<%= i18n.__(\'linearMeasurement\') %>

\n

<%= model.lengthDisplay %>

\n'),o=c.template('

<%= i18n.__(\'areaMeasurement\') %>

\n

<%= 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 1) { - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; - } - } - queue.push(new Item(fun, args)); - if (queue.length === 1 && !draining) { - runTimeout(drainQueue); - } -}; - -// v8 likes predictible objects -function Item(fun, array) { - this.fun = fun; - this.array = array; -} -Item.prototype.run = function () { - this.fun.apply(null, this.array); -}; -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; -process.version = ''; // empty string to avoid regexp issues -process.versions = {}; - -function noop() {} - -process.on = noop; -process.addListener = noop; -process.once = noop; -process.off = noop; -process.removeListener = noop; -process.removeAllListeners = noop; -process.emit = noop; - -process.binding = function (name) { - throw new Error('process.binding is not supported'); -}; - -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); -}; -process.umask = function() { return 0; }; - -},{}],4:[function(require,module,exports){ -function corslite(url, callback, cors) { - var sent = false; - - if (typeof window.XMLHttpRequest === 'undefined') { - return callback(Error('Browser not supported')); - } - - if (typeof cors === 'undefined') { - var m = url.match(/^\s*https?:\/\/[^\/]*/); - cors = m && (m[0] !== location.protocol + '//' + location.hostname + - (location.port ? ':' + location.port : '')); - } - - var x = new window.XMLHttpRequest(); - - function isSuccessful(status) { - return status >= 200 && status < 300 || status === 304; - } - - if (cors && !('withCredentials' in x)) { - // IE8-9 - x = new window.XDomainRequest(); - - // Ensure callback is never called synchronously, i.e., before - // x.send() returns (this has been observed in the wild). - // See https://github.com/mapbox/mapbox.js/issues/472 - var original = callback; - callback = function() { - if (sent) { - original.apply(this, arguments); - } else { - var that = this, args = arguments; - setTimeout(function() { - original.apply(that, args); - }, 0); - } - } - } - - function loaded() { - if ( - // XDomainRequest - x.status === undefined || - // modern browsers - isSuccessful(x.status)) callback.call(x, null, x); - else callback.call(x, x, null); - } - - // Both `onreadystatechange` and `onload` can fire. `onreadystatechange` - // has [been supported for longer](http://stackoverflow.com/a/9181508/229001). - if ('onload' in x) { - x.onload = loaded; - } else { - x.onreadystatechange = function readystate() { - if (x.readyState === 4) { - loaded(); - } - }; - } - - // Call the callback with the XMLHttpRequest object as an error and prevent - // it from ever being called again by reassigning it to `noop` - x.onerror = function error(evt) { - // XDomainRequest provides no evt parameter - callback.call(this, evt || true, null); - callback = function() { }; - }; - - // IE9 must have onprogress be set to a unique function. - x.onprogress = function() { }; - - x.ontimeout = function(evt) { - callback.call(this, evt, null); - callback = function() { }; - }; - - x.onabort = function(evt) { - callback.call(this, evt, null); - callback = function() { }; - }; - - // GET is the only supported HTTP Verb by XDomainRequest and is the - // only one supported here. - x.open('GET', url, true); - - // Send the request. Sending data is not supported. - x.send(null); - sent = true; - - return x; -} - -if (typeof module !== 'undefined') module.exports = corslite; - -},{}],5:[function(require,module,exports){ -'use strict'; - -var dsv = require('d3-dsv'), - sexagesimal = require('sexagesimal'); - -var latRegex = /(Lat)(itude)?/gi, - lonRegex = /(L)(on|ng)(gitude)?/i; - -function guessHeader(row, regexp) { - var name, match, score; - for (var f in row) { - match = f.match(regexp); - if (match && (!name || match[0].length / f.length > score)) { - score = match[0].length / f.length; - name = f; - } - } - return name; -} - -function guessLatHeader(row) { return guessHeader(row, latRegex); } -function guessLonHeader(row) { return guessHeader(row, lonRegex); } - -function isLat(f) { return !!f.match(latRegex); } -function isLon(f) { return !!f.match(lonRegex); } - -function keyCount(o) { - return (typeof o == 'object') ? Object.keys(o).length : 0; -} - -function autoDelimiter(x) { - var delimiters = [',', ';', '\t', '|']; - var results = []; - - delimiters.forEach(function (delimiter) { - var res = dsv.dsvFormat(delimiter).parse(x); - if (res.length >= 1) { - var count = keyCount(res[0]); - for (var i = 0; i < res.length; i++) { - if (keyCount(res[i]) !== count) return; - } - results.push({ - delimiter: delimiter, - arity: Object.keys(res[0]).length, - }); - } - }); - - if (results.length) { - return results.sort(function (a, b) { - return b.arity - a.arity; - })[0].delimiter; - } else { - return null; - } -} - -/** - * Silly stopgap for dsv to d3-dsv upgrade - * - * @param {Array} x dsv output - * @returns {Array} array without columns member - */ -function deleteColumns(x) { - delete x.columns; - return x; -} - -function auto(x) { - var delimiter = autoDelimiter(x); - if (!delimiter) return null; - return deleteColumns(dsv.dsvFormat(delimiter).parse(x)); -} - -function csv2geojson(x, options, callback) { - - if (!callback) { - callback = options; - options = {}; - } - - options.delimiter = options.delimiter || ','; - - var latfield = options.latfield || '', - lonfield = options.lonfield || '', - crs = options.crs || ''; - - var features = [], - featurecollection = {type: 'FeatureCollection', features: features}; - - if (crs !== '') { - featurecollection.crs = {type: 'name', properties: {name: crs}}; - } - - if (options.delimiter === 'auto' && typeof x == 'string') { - options.delimiter = autoDelimiter(x); - if (!options.delimiter) { - callback({ - type: 'Error', - message: 'Could not autodetect delimiter' - }); - return; - } - } - - var parsed = (typeof x == 'string') ? - dsv.dsvFormat(options.delimiter).parse(x) : x; - - if (!parsed.length) { - callback(null, featurecollection); - return; - } - - var errors = []; - var i; - - - if (!latfield) latfield = guessLatHeader(parsed[0]); - if (!lonfield) lonfield = guessLonHeader(parsed[0]); - var noGeometry = (!latfield || !lonfield); - - if (noGeometry) { - for (i = 0; i < parsed.length; i++) { - features.push({ - type: 'Feature', - properties: parsed[i], - geometry: null - }); - } - callback(errors.length ? errors : null, featurecollection); - return; - } - - for (i = 0; i < parsed.length; i++) { - if (parsed[i][lonfield] !== undefined && - parsed[i][latfield] !== undefined) { - - var lonk = parsed[i][lonfield], - latk = parsed[i][latfield], - lonf, latf, - a; - - a = sexagesimal(lonk, 'EW'); - if (a) lonk = a; - a = sexagesimal(latk, 'NS'); - if (a) latk = a; - - lonf = parseFloat(lonk); - latf = parseFloat(latk); - - if (isNaN(lonf) || - isNaN(latf)) { - errors.push({ - message: 'A row contained an invalid value for latitude or longitude', - row: parsed[i], - index: i - }); - } else { - if (!options.includeLatLon) { - delete parsed[i][lonfield]; - delete parsed[i][latfield]; - } - - features.push({ - type: 'Feature', - properties: parsed[i], - geometry: { - type: 'Point', - coordinates: [ - parseFloat(lonf), - parseFloat(latf) - ] - } - }); - } - } - } - - callback(errors.length ? errors : null, featurecollection); -} - -function toLine(gj) { - var features = gj.features; - var line = { - type: 'Feature', - geometry: { - type: 'LineString', - coordinates: [] - } - }; - for (var i = 0; i < features.length; i++) { - line.geometry.coordinates.push(features[i].geometry.coordinates); - } - line.properties = features.reduce(function (aggregatedProperties, newFeature) { - for (var key in newFeature.properties) { - if (!aggregatedProperties[key]) { - aggregatedProperties[key] = []; - } - aggregatedProperties[key].push(newFeature.properties[key]); - } - return aggregatedProperties; - }, {}); - return { - type: 'FeatureCollection', - features: [line] - }; -} - -function toPolygon(gj) { - var features = gj.features; - var poly = { - type: 'Feature', - geometry: { - type: 'Polygon', - coordinates: [[]] - } - }; - for (var i = 0; i < features.length; i++) { - poly.geometry.coordinates[0].push(features[i].geometry.coordinates); - } - poly.properties = features.reduce(function (aggregatedProperties, newFeature) { - for (var key in newFeature.properties) { - if (!aggregatedProperties[key]) { - aggregatedProperties[key] = []; - } - aggregatedProperties[key].push(newFeature.properties[key]); - } - return aggregatedProperties; - }, {}); - return { - type: 'FeatureCollection', - features: [poly] - }; -} - -module.exports = { - isLon: isLon, - isLat: isLat, - guessLatHeader: guessLatHeader, - guessLonHeader: guessLonHeader, - csv: dsv.csvParse, - tsv: dsv.tsvParse, - dsv: dsv, - auto: auto, - csv2geojson: csv2geojson, - toLine: toLine, - toPolygon: toPolygon -}; - -},{"d3-dsv":6,"sexagesimal":7}],6:[function(require,module,exports){ -// https://d3js.org/d3-dsv/ Version 1.0.1. Copyright 2016 Mike Bostock. -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : - typeof define === 'function' && define.amd ? define(['exports'], factory) : - (factory((global.d3 = global.d3 || {}))); -}(this, function (exports) { 'use strict'; - - function objectConverter(columns) { - return new Function("d", "return {" + columns.map(function(name, i) { - return JSON.stringify(name) + ": d[" + i + "]"; - }).join(",") + "}"); - } - - function customConverter(columns, f) { - var object = objectConverter(columns); - return function(row, i) { - return f(object(row), i, columns); - }; - } - - // Compute unique columns in order of discovery. - function inferColumns(rows) { - var columnSet = Object.create(null), - columns = []; - - rows.forEach(function(row) { - for (var column in row) { - if (!(column in columnSet)) { - columns.push(columnSet[column] = column); - } - } - }); - - return columns; - } - - function dsv(delimiter) { - var reFormat = new RegExp("[\"" + delimiter + "\n]"), - delimiterCode = delimiter.charCodeAt(0); - - function parse(text, f) { - var convert, columns, rows = parseRows(text, function(row, i) { - if (convert) return convert(row, i - 1); - columns = row, convert = f ? customConverter(row, f) : objectConverter(row); - }); - rows.columns = columns; - return rows; - } - - function parseRows(text, f) { - var EOL = {}, // sentinel value for end-of-line - EOF = {}, // sentinel value for end-of-file - rows = [], // output rows - N = text.length, - I = 0, // current character index - n = 0, // the current line number - t, // the current token - eol; // is the current token followed by EOL? - - function token() { - if (I >= N) return EOF; // special case: end of file - if (eol) return eol = false, EOL; // special case: end of line - - // special case: quotes - var j = I, c; - if (text.charCodeAt(j) === 34) { - var i = j; - while (i++ < N) { - if (text.charCodeAt(i) === 34) { - if (text.charCodeAt(i + 1) !== 34) break; - ++i; - } - } - I = i + 2; - c = text.charCodeAt(i + 1); - if (c === 13) { - eol = true; - if (text.charCodeAt(i + 2) === 10) ++I; - } else if (c === 10) { - eol = true; - } - return text.slice(j + 1, i).replace(/""/g, "\""); - } - - // common case: find next delimiter or newline - while (I < N) { - var k = 1; - c = text.charCodeAt(I++); - if (c === 10) eol = true; // \n - else if (c === 13) { eol = true; if (text.charCodeAt(I) === 10) ++I, ++k; } // \r|\r\n - else if (c !== delimiterCode) continue; - return text.slice(j, I - k); - } - - // special case: last token before EOF - return text.slice(j); - } - - while ((t = token()) !== EOF) { - var a = []; - while (t !== EOL && t !== EOF) { - a.push(t); - t = token(); - } - if (f && (a = f(a, n++)) == null) continue; - rows.push(a); - } - - return rows; - } - - function format(rows, columns) { - if (columns == null) columns = inferColumns(rows); - return [columns.map(formatValue).join(delimiter)].concat(rows.map(function(row) { - return columns.map(function(column) { - return formatValue(row[column]); - }).join(delimiter); - })).join("\n"); - } - - function formatRows(rows) { - return rows.map(formatRow).join("\n"); - } - - function formatRow(row) { - return row.map(formatValue).join(delimiter); - } - - function formatValue(text) { - return text == null ? "" - : reFormat.test(text += "") ? "\"" + text.replace(/\"/g, "\"\"") + "\"" - : text; - } - - return { - parse: parse, - parseRows: parseRows, - format: format, - formatRows: formatRows - }; - } - - var csv = dsv(","); - - var csvParse = csv.parse; - var csvParseRows = csv.parseRows; - var csvFormat = csv.format; - var csvFormatRows = csv.formatRows; - - var tsv = dsv("\t"); - - var tsvParse = tsv.parse; - var tsvParseRows = tsv.parseRows; - var tsvFormat = tsv.format; - var tsvFormatRows = tsv.formatRows; - - exports.dsvFormat = dsv; - exports.csvParse = csvParse; - exports.csvParseRows = csvParseRows; - exports.csvFormat = csvFormat; - exports.csvFormatRows = csvFormatRows; - exports.tsvParse = tsvParse; - exports.tsvParseRows = tsvParseRows; - exports.tsvFormat = tsvFormat; - exports.tsvFormatRows = tsvFormatRows; - - Object.defineProperty(exports, '__esModule', { value: true }); - -})); -},{}],7:[function(require,module,exports){ -module.exports = element; -module.exports.pair = pair; -module.exports.format = format; -module.exports.formatPair = formatPair; -module.exports.coordToDMS = coordToDMS; - -function element(x, dims) { - return search(x, dims).val; -} - -function formatPair(x) { - return format(x.lat, 'lat') + ' ' + format(x.lon, 'lon'); -} - -// Is 0 North or South? -function format(x, dim) { - var dms = coordToDMS(x,dim); - return dms.whole + '° ' + - (dms.minutes ? dms.minutes + '\' ' : '') + - (dms.seconds ? dms.seconds + '" ' : '') + dms.dir; -} - -function coordToDMS(x,dim) { - var dirs = { - lat: ['N', 'S'], - lon: ['E', 'W'] - }[dim] || '', - dir = dirs[x >= 0 ? 0 : 1], - abs = Math.abs(x), - whole = Math.floor(abs), - fraction = abs - whole, - fractionMinutes = fraction * 60, - minutes = Math.floor(fractionMinutes), - seconds = Math.floor((fractionMinutes - minutes) * 60); - - return { - whole: whole, - minutes: minutes, - seconds: seconds, - dir: dir - }; -} - -function search(x, dims, r) { - if (!dims) dims = 'NSEW'; - if (typeof x !== 'string') return { val: null, regex: r }; - r = r || /[\s\,]*([\-|\—|\―]?[0-9.]+)°? *(?:([0-9.]+)['’′‘] *)?(?:([0-9.]+)(?:''|"|”|″) *)?([NSEW])?/gi; - var m = r.exec(x); - if (!m) return { val: null, regex: r }; - else if (m[4] && dims.indexOf(m[4]) === -1) return { val: null, regex: r }; - else return { - val: (((m[1]) ? parseFloat(m[1]) : 0) + - ((m[2] ? parseFloat(m[2]) / 60 : 0)) + - ((m[3] ? parseFloat(m[3]) / 3600 : 0))) * - ((m[4] && m[4] === 'S' || m[4] === 'W') ? -1 : 1), - regex: r, - raw: m[0], - dim: m[4] - }; -} - -function pair(x, dims) { - x = x.trim(); - var one = search(x, dims); - if (one.val === null) return null; - var two = search(x, dims, one.regex); - if (two.val === null) return null; - // null if one/two are not contiguous. - if (one.raw + two.raw !== x) return null; - if (one.dim) { - return swapdim(one.val, two.val, one.dim); - } else { - return [one.val, two.val]; - } -} - -function swapdim(a, b, dim) { - if (dim === 'N' || dim === 'S') return [a, b]; - if (dim === 'W' || dim === 'E') return [b, a]; -} - -},{}],8:[function(require,module,exports){ -'use strict'; - -/** - * Based off of [the offical Google document](https://developers.google.com/maps/documentation/utilities/polylinealgorithm) - * - * Some parts from [this implementation](http://facstaff.unca.edu/mcmcclur/GoogleMaps/EncodePolyline/PolylineEncoder.js) - * by [Mark McClure](http://facstaff.unca.edu/mcmcclur/) - * - * @module polyline - */ - -var polyline = {}; - -function encode(coordinate, factor) { - coordinate = Math.round(coordinate * factor); - coordinate <<= 1; - if (coordinate < 0) { - coordinate = ~coordinate; - } - var output = ''; - while (coordinate >= 0x20) { - output += String.fromCharCode((0x20 | (coordinate & 0x1f)) + 63); - coordinate >>= 5; - } - output += String.fromCharCode(coordinate + 63); - return output; -} - -/** - * Decodes to a [latitude, longitude] coordinates array. - * - * This is adapted from the implementation in Project-OSRM. - * - * @param {String} str - * @param {Number} precision - * @returns {Array} - * - * @see https://github.com/Project-OSRM/osrm-frontend/blob/master/WebContent/routing/OSRM.RoutingGeometry.js - */ -polyline.decode = function(str, precision) { - var index = 0, - lat = 0, - lng = 0, - coordinates = [], - shift = 0, - result = 0, - byte = null, - latitude_change, - longitude_change, - factor = Math.pow(10, precision || 5); - - // Coordinates have variable length when encoded, so just keep - // track of whether we've hit the end of the string. In each - // loop iteration, a single coordinate is decoded. - while (index < str.length) { - - // Reset shift, result, and byte - byte = null; - shift = 0; - result = 0; - - do { - byte = str.charCodeAt(index++) - 63; - result |= (byte & 0x1f) << shift; - shift += 5; - } while (byte >= 0x20); - - latitude_change = ((result & 1) ? ~(result >> 1) : (result >> 1)); - - shift = result = 0; - - do { - byte = str.charCodeAt(index++) - 63; - result |= (byte & 0x1f) << shift; - shift += 5; - } while (byte >= 0x20); - - longitude_change = ((result & 1) ? ~(result >> 1) : (result >> 1)); - - lat += latitude_change; - lng += longitude_change; - - coordinates.push([lat / factor, lng / factor]); - } - - return coordinates; -}; - -/** - * Encodes the given [latitude, longitude] coordinates array. - * - * @param {Array.>} coordinates - * @param {Number} precision - * @returns {String} - */ -polyline.encode = function(coordinates, precision) { - if (!coordinates.length) { return ''; } - - var factor = Math.pow(10, precision || 5), - output = encode(coordinates[0][0], factor) + encode(coordinates[0][1], factor); - - for (var i = 1; i < coordinates.length; i++) { - var a = coordinates[i], b = coordinates[i - 1]; - output += encode(a[0] - b[0], factor); - output += encode(a[1] - b[1], factor); - } - - return output; -}; - -function flipped(coords) { - var flipped = []; - for (var i = 0; i < coords.length; i++) { - flipped.push(coords[i].slice().reverse()); - } - return flipped; -} - -/** - * Encodes a GeoJSON LineString feature/geometry. - * - * @param {Object} geojson - * @param {Number} precision - * @returns {String} - */ -polyline.fromGeoJSON = function(geojson, precision) { - if (geojson && geojson.type === 'Feature') { - geojson = geojson.geometry; - } - if (!geojson || geojson.type !== 'LineString') { - throw new Error('Input must be a GeoJSON LineString'); - } - return polyline.encode(flipped(geojson.coordinates), precision); -}; - -/** - * Decodes to a GeoJSON LineString geometry. - * - * @param {String} str - * @param {Number} precision - * @returns {Object} - */ -polyline.toGeoJSON = function(str, precision) { - var coords = polyline.decode(str, precision); - return { - type: 'LineString', - coordinates: flipped(coords) - }; -}; - -if (typeof module === 'object' && module.exports) { - module.exports = polyline; -} - -},{}],9:[function(require,module,exports){ -(function (process){ -var toGeoJSON = (function() { - 'use strict'; - - var removeSpace = (/\s*/g), - trimSpace = (/^\s*|\s*$/g), - splitSpace = (/\s+/); - // generate a short, numeric hash of a string - function okhash(x) { - if (!x || !x.length) return 0; - for (var i = 0, h = 0; i < x.length; i++) { - h = ((h << 5) - h) + x.charCodeAt(i) | 0; - } return h; - } - // all Y children of X - function get(x, y) { return x.getElementsByTagName(y); } - function attr(x, y) { return x.getAttribute(y); } - function attrf(x, y) { return parseFloat(attr(x, y)); } - // one Y child of X, if any, otherwise null - function get1(x, y) { var n = get(x, y); return n.length ? n[0] : null; } - // https://developer.mozilla.org/en-US/docs/Web/API/Node.normalize - function norm(el) { if (el.normalize) { el.normalize(); } return el; } - // cast array x into numbers - function numarray(x) { - for (var j = 0, o = []; j < x.length; j++) { o[j] = parseFloat(x[j]); } - return o; - } - function clean(x) { - var o = {}; - for (var i in x) { if (x[i]) { o[i] = x[i]; } } - return o; - } - // get the content of a text node, if any - function nodeVal(x) { - if (x) { norm(x); } - return (x && x.textContent) || ''; - } - // get one coordinate from a coordinate array, if any - function coord1(v) { return numarray(v.replace(removeSpace, '').split(',')); } - // get all coordinates from a coordinate array as [[],[]] - function coord(v) { - var coords = v.replace(trimSpace, '').split(splitSpace), - o = []; - for (var i = 0; i < coords.length; i++) { - o.push(coord1(coords[i])); - } - return o; - } - function coordPair(x) { - var ll = [attrf(x, 'lon'), attrf(x, 'lat')], - ele = get1(x, 'ele'), - // handle namespaced attribute in browser - heartRate = get1(x, 'gpxtpx:hr') || get1(x, 'hr'), - time = get1(x, 'time'), - e; - if (ele) { - e = parseFloat(nodeVal(ele)); - if (!isNaN(e)) { - ll.push(e); - } - } - return { - coordinates: ll, - time: time ? nodeVal(time) : null, - heartRate: heartRate ? parseFloat(nodeVal(heartRate)) : null - }; - } - - // create a new feature collection parent object - function fc() { - return { - type: 'FeatureCollection', - features: [] - }; - } - - var serializer; - if (typeof XMLSerializer !== 'undefined') { - /* istanbul ignore next */ - serializer = new XMLSerializer(); - // only require xmldom in a node environment - } else if (typeof exports === 'object' && typeof process === 'object' && !process.browser) { - serializer = new (require('xmldom').XMLSerializer)(); - } - function xml2str(str) { - // IE9 will create a new XMLSerializer but it'll crash immediately. - // This line is ignored because we don't run coverage tests in IE9 - /* istanbul ignore next */ - if (str.xml !== undefined) return str.xml; - return serializer.serializeToString(str); - } - - var t = { - kml: function(doc) { - - var gj = fc(), - // styleindex keeps track of hashed styles in order to match features - styleIndex = {}, - // atomic geospatial types supported by KML - MultiGeometry is - // handled separately - geotypes = ['Polygon', 'LineString', 'Point', 'Track', 'gx:Track'], - // all root placemarks in the file - placemarks = get(doc, 'Placemark'), - styles = get(doc, 'Style'), - styleMaps = get(doc, 'StyleMap'); - - for (var k = 0; k < styles.length; k++) { - styleIndex['#' + attr(styles[k], 'id')] = okhash(xml2str(styles[k])).toString(16); - } - for (var l = 0; l < styleMaps.length; l++) { - styleIndex['#' + attr(styleMaps[l], 'id')] = okhash(xml2str(styleMaps[l])).toString(16); - } - for (var j = 0; j < placemarks.length; j++) { - gj.features = gj.features.concat(getPlacemark(placemarks[j])); - } - function kmlColor(v) { - var color, opacity; - v = v || ''; - if (v.substr(0, 1) === '#') { v = v.substr(1); } - if (v.length === 6 || v.length === 3) { color = v; } - if (v.length === 8) { - opacity = parseInt(v.substr(0, 2), 16) / 255; - color = '#'+v.substr(2); - } - return [color, isNaN(opacity) ? undefined : opacity]; - } - function gxCoord(v) { return numarray(v.split(' ')); } - function gxCoords(root) { - var elems = get(root, 'coord', 'gx'), coords = [], times = []; - if (elems.length === 0) elems = get(root, 'gx:coord'); - for (var i = 0; i < elems.length; i++) coords.push(gxCoord(nodeVal(elems[i]))); - var timeElems = get(root, 'when'); - for (var j = 0; j < timeElems.length; j++) times.push(nodeVal(timeElems[j])); - return { - coords: coords, - times: times - }; - } - function getGeometry(root) { - var geomNode, geomNodes, i, j, k, geoms = [], coordTimes = []; - if (get1(root, 'MultiGeometry')) { return getGeometry(get1(root, 'MultiGeometry')); } - if (get1(root, 'MultiTrack')) { return getGeometry(get1(root, 'MultiTrack')); } - if (get1(root, 'gx:MultiTrack')) { return getGeometry(get1(root, 'gx:MultiTrack')); } - for (i = 0; i < geotypes.length; i++) { - geomNodes = get(root, geotypes[i]); - if (geomNodes) { - for (j = 0; j < geomNodes.length; j++) { - geomNode = geomNodes[j]; - if (geotypes[i] === 'Point') { - geoms.push({ - type: 'Point', - coordinates: coord1(nodeVal(get1(geomNode, 'coordinates'))) - }); - } else if (geotypes[i] === 'LineString') { - geoms.push({ - type: 'LineString', - coordinates: coord(nodeVal(get1(geomNode, 'coordinates'))) - }); - } else if (geotypes[i] === 'Polygon') { - var rings = get(geomNode, 'LinearRing'), - coords = []; - for (k = 0; k < rings.length; k++) { - coords.push(coord(nodeVal(get1(rings[k], 'coordinates')))); - } - geoms.push({ - type: 'Polygon', - coordinates: coords - }); - } else if (geotypes[i] === 'Track' || - geotypes[i] === 'gx:Track') { - var track = gxCoords(geomNode); - geoms.push({ - type: 'LineString', - coordinates: track.coords - }); - if (track.times.length) coordTimes.push(track.times); - } - } - } - } - return { - geoms: geoms, - coordTimes: coordTimes - }; - } - function getPlacemark(root) { - var geomsAndTimes = getGeometry(root), i, properties = {}, - name = nodeVal(get1(root, 'name')), - styleUrl = nodeVal(get1(root, 'styleUrl')), - description = nodeVal(get1(root, 'description')), - timeSpan = get1(root, 'TimeSpan'), - extendedData = get1(root, 'ExtendedData'), - lineStyle = get1(root, 'LineStyle'), - polyStyle = get1(root, 'PolyStyle'); - - if (!geomsAndTimes.geoms.length) return []; - if (name) properties.name = name; - if (styleUrl[0] !== '#') { - styleUrl = '#' + styleUrl; - } - if (styleUrl && styleIndex[styleUrl]) { - properties.styleUrl = styleUrl; - properties.styleHash = styleIndex[styleUrl]; - } - if (description) properties.description = description; - if (timeSpan) { - var begin = nodeVal(get1(timeSpan, 'begin')); - var end = nodeVal(get1(timeSpan, 'end')); - properties.timespan = { begin: begin, end: end }; - } - if (lineStyle) { - var linestyles = kmlColor(nodeVal(get1(lineStyle, 'color'))), - color = linestyles[0], - opacity = linestyles[1], - width = parseFloat(nodeVal(get1(lineStyle, 'width'))); - if (color) properties.stroke = color; - if (!isNaN(opacity)) properties['stroke-opacity'] = opacity; - if (!isNaN(width)) properties['stroke-width'] = width; - } - if (polyStyle) { - var polystyles = kmlColor(nodeVal(get1(polyStyle, 'color'))), - pcolor = polystyles[0], - popacity = polystyles[1], - fill = nodeVal(get1(polyStyle, 'fill')), - outline = nodeVal(get1(polyStyle, 'outline')); - if (pcolor) properties.fill = pcolor; - if (!isNaN(popacity)) properties['fill-opacity'] = popacity; - if (fill) properties['fill-opacity'] = fill === '1' ? 1 : 0; - if (outline) properties['stroke-opacity'] = outline === '1' ? 1 : 0; - } - if (extendedData) { - var datas = get(extendedData, 'Data'), - simpleDatas = get(extendedData, 'SimpleData'); - - for (i = 0; i < datas.length; i++) { - properties[datas[i].getAttribute('name')] = nodeVal(get1(datas[i], 'value')); - } - for (i = 0; i < simpleDatas.length; i++) { - properties[simpleDatas[i].getAttribute('name')] = nodeVal(simpleDatas[i]); - } - } - if (geomsAndTimes.coordTimes.length) { - properties.coordTimes = (geomsAndTimes.coordTimes.length === 1) ? - geomsAndTimes.coordTimes[0] : geomsAndTimes.coordTimes; - } - var feature = { - type: 'Feature', - geometry: (geomsAndTimes.geoms.length === 1) ? geomsAndTimes.geoms[0] : { - type: 'GeometryCollection', - geometries: geomsAndTimes.geoms - }, - properties: properties - }; - if (attr(root, 'id')) feature.id = attr(root, 'id'); - return [feature]; - } - return gj; - }, - gpx: function(doc) { - var i, - tracks = get(doc, 'trk'), - routes = get(doc, 'rte'), - waypoints = get(doc, 'wpt'), - // a feature collection - gj = fc(), - feature; - for (i = 0; i < tracks.length; i++) { - feature = getTrack(tracks[i]); - if (feature) gj.features.push(feature); - } - for (i = 0; i < routes.length; i++) { - feature = getRoute(routes[i]); - if (feature) gj.features.push(feature); - } - for (i = 0; i < waypoints.length; i++) { - gj.features.push(getPoint(waypoints[i])); - } - function getPoints(node, pointname) { - var pts = get(node, pointname), - line = [], - times = [], - heartRates = [], - l = pts.length; - if (l < 2) return {}; // Invalid line in GeoJSON - for (var i = 0; i < l; i++) { - var c = coordPair(pts[i]); - line.push(c.coordinates); - if (c.time) times.push(c.time); - if (c.heartRate) heartRates.push(c.heartRate); - } - return { - line: line, - times: times, - heartRates: heartRates - }; - } - function getTrack(node) { - var segments = get(node, 'trkseg'), - track = [], - times = [], - heartRates = [], - line; - for (var i = 0; i < segments.length; i++) { - line = getPoints(segments[i], 'trkpt'); - if (line.line) track.push(line.line); - if (line.times && line.times.length) times.push(line.times); - if (line.heartRates && line.heartRates.length) heartRates.push(line.heartRates); - } - if (track.length === 0) return; - var properties = getProperties(node); - if (times.length) properties.coordTimes = track.length === 1 ? times[0] : times; - if (heartRates.length) properties.heartRates = track.length === 1 ? heartRates[0] : heartRates; - return { - type: 'Feature', - properties: properties, - geometry: { - type: track.length === 1 ? 'LineString' : 'MultiLineString', - coordinates: track.length === 1 ? track[0] : track - } - }; - } - function getRoute(node) { - var line = getPoints(node, 'rtept'); - if (!line.line) return; - var routeObj = { - type: 'Feature', - properties: getProperties(node), - geometry: { - type: 'LineString', - coordinates: line.line - } - }; - return routeObj; - } - function getPoint(node) { - var prop = getProperties(node); - prop.sym = nodeVal(get1(node, 'sym')); - return { - type: 'Feature', - properties: prop, - geometry: { - type: 'Point', - coordinates: coordPair(node).coordinates - } - }; - } - function getProperties(node) { - var meta = ['name', 'desc', 'author', 'copyright', 'link', - 'time', 'keywords'], - prop = {}, - k; - for (k = 0; k < meta.length; k++) { - prop[meta[k]] = nodeVal(get1(node, meta[k])); - } - return clean(prop); - } - return gj; - } - }; - return t; -})(); - -if (typeof module !== 'undefined') module.exports = toGeoJSON; - -}).call(this,require('_process')) -},{"_process":3,"xmldom":2}],10:[function(require,module,exports){ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : - typeof define === 'function' && define.amd ? define(['exports'], factory) : - (factory((global.topojson = global.topojson || {}))); -}(this, function (exports) { 'use strict'; - - function noop() {} - - function transformAbsolute(transform) { - if (!transform) return noop; - var x0, - y0, - kx = transform.scale[0], - ky = transform.scale[1], - dx = transform.translate[0], - dy = transform.translate[1]; - return function(point, i) { - if (!i) x0 = y0 = 0; - point[0] = (x0 += point[0]) * kx + dx; - point[1] = (y0 += point[1]) * ky + dy; - }; - } - - function transformRelative(transform) { - if (!transform) return noop; - var x0, - y0, - kx = transform.scale[0], - ky = transform.scale[1], - dx = transform.translate[0], - dy = transform.translate[1]; - return function(point, i) { - if (!i) x0 = y0 = 0; - var x1 = Math.round((point[0] - dx) / kx), - y1 = Math.round((point[1] - dy) / ky); - point[0] = x1 - x0; - point[1] = y1 - y0; - x0 = x1; - y0 = y1; - }; - } - - function reverse(array, n) { - var t, j = array.length, i = j - n; - while (i < --j) t = array[i], array[i++] = array[j], array[j] = t; - } - - function bisect(a, x) { - var lo = 0, hi = a.length; - while (lo < hi) { - var mid = lo + hi >>> 1; - if (a[mid] < x) lo = mid + 1; - else hi = mid; - } - return lo; - } - - function feature(topology, o) { - return o.type === "GeometryCollection" ? { - type: "FeatureCollection", - features: o.geometries.map(function(o) { return feature$1(topology, o); }) - } : feature$1(topology, o); - } - - function feature$1(topology, o) { - var f = { - type: "Feature", - id: o.id, - properties: o.properties || {}, - geometry: object(topology, o) - }; - if (o.id == null) delete f.id; - return f; - } - - function object(topology, o) { - var absolute = transformAbsolute(topology.transform), - arcs = topology.arcs; - - function arc(i, points) { - if (points.length) points.pop(); - for (var a = arcs[i < 0 ? ~i : i], k = 0, n = a.length, p; k < n; ++k) { - points.push(p = a[k].slice()); - absolute(p, k); - } - if (i < 0) reverse(points, n); - } - - function point(p) { - p = p.slice(); - absolute(p, 0); - return p; - } - - function line(arcs) { - var points = []; - for (var i = 0, n = arcs.length; i < n; ++i) arc(arcs[i], points); - if (points.length < 2) points.push(points[0].slice()); - return points; - } - - function ring(arcs) { - var points = line(arcs); - while (points.length < 4) points.push(points[0].slice()); - return points; - } - - function polygon(arcs) { - return arcs.map(ring); - } - - function geometry(o) { - var t = o.type; - return t === "GeometryCollection" ? {type: t, geometries: o.geometries.map(geometry)} - : t in geometryType ? {type: t, coordinates: geometryType[t](o)} - : null; - } - - var geometryType = { - Point: function(o) { return point(o.coordinates); }, - MultiPoint: function(o) { return o.coordinates.map(point); }, - LineString: function(o) { return line(o.arcs); }, - MultiLineString: function(o) { return o.arcs.map(line); }, - Polygon: function(o) { return polygon(o.arcs); }, - MultiPolygon: function(o) { return o.arcs.map(polygon); } - }; - - return geometry(o); - } - - function stitchArcs(topology, arcs) { - var stitchedArcs = {}, - fragmentByStart = {}, - fragmentByEnd = {}, - fragments = [], - emptyIndex = -1; - - // Stitch empty arcs first, since they may be subsumed by other arcs. - arcs.forEach(function(i, j) { - var arc = topology.arcs[i < 0 ? ~i : i], t; - if (arc.length < 3 && !arc[1][0] && !arc[1][1]) { - t = arcs[++emptyIndex], arcs[emptyIndex] = i, arcs[j] = t; - } - }); - - arcs.forEach(function(i) { - var e = ends(i), - start = e[0], - end = e[1], - f, g; - - if (f = fragmentByEnd[start]) { - delete fragmentByEnd[f.end]; - f.push(i); - f.end = end; - if (g = fragmentByStart[end]) { - delete fragmentByStart[g.start]; - var fg = g === f ? f : f.concat(g); - fragmentByStart[fg.start = f.start] = fragmentByEnd[fg.end = g.end] = fg; - } else { - fragmentByStart[f.start] = fragmentByEnd[f.end] = f; - } - } else if (f = fragmentByStart[end]) { - delete fragmentByStart[f.start]; - f.unshift(i); - f.start = start; - if (g = fragmentByEnd[start]) { - delete fragmentByEnd[g.end]; - var gf = g === f ? f : g.concat(f); - fragmentByStart[gf.start = g.start] = fragmentByEnd[gf.end = f.end] = gf; - } else { - fragmentByStart[f.start] = fragmentByEnd[f.end] = f; - } - } else { - f = [i]; - fragmentByStart[f.start = start] = fragmentByEnd[f.end = end] = f; - } - }); - - function ends(i) { - var arc = topology.arcs[i < 0 ? ~i : i], p0 = arc[0], p1; - if (topology.transform) p1 = [0, 0], arc.forEach(function(dp) { p1[0] += dp[0], p1[1] += dp[1]; }); - else p1 = arc[arc.length - 1]; - return i < 0 ? [p1, p0] : [p0, p1]; - } - - function flush(fragmentByEnd, fragmentByStart) { - for (var k in fragmentByEnd) { - var f = fragmentByEnd[k]; - delete fragmentByStart[f.start]; - delete f.start; - delete f.end; - f.forEach(function(i) { stitchedArcs[i < 0 ? ~i : i] = 1; }); - fragments.push(f); - } - } - - flush(fragmentByEnd, fragmentByStart); - flush(fragmentByStart, fragmentByEnd); - arcs.forEach(function(i) { if (!stitchedArcs[i < 0 ? ~i : i]) fragments.push([i]); }); - - return fragments; - } - - function mesh(topology) { - return object(topology, meshArcs.apply(this, arguments)); - } - - function meshArcs(topology, o, filter) { - var arcs = []; - - function arc(i) { - var j = i < 0 ? ~i : i; - (geomsByArc[j] || (geomsByArc[j] = [])).push({i: i, g: geom}); - } - - function line(arcs) { - arcs.forEach(arc); - } - - function polygon(arcs) { - arcs.forEach(line); - } - - function geometry(o) { - if (o.type === "GeometryCollection") o.geometries.forEach(geometry); - else if (o.type in geometryType) geom = o, geometryType[o.type](o.arcs); - } - - if (arguments.length > 1) { - var geomsByArc = [], - geom; - - var geometryType = { - LineString: line, - MultiLineString: polygon, - Polygon: polygon, - MultiPolygon: function(arcs) { arcs.forEach(polygon); } - }; - - geometry(o); - - geomsByArc.forEach(arguments.length < 3 - ? function(geoms) { arcs.push(geoms[0].i); } - : function(geoms) { if (filter(geoms[0].g, geoms[geoms.length - 1].g)) arcs.push(geoms[0].i); }); - } else { - for (var i = 0, n = topology.arcs.length; i < n; ++i) arcs.push(i); - } - - return {type: "MultiLineString", arcs: stitchArcs(topology, arcs)}; - } - - function cartesianTriangleArea(triangle) { - var a = triangle[0], b = triangle[1], c = triangle[2]; - return Math.abs((a[0] - c[0]) * (b[1] - a[1]) - (a[0] - b[0]) * (c[1] - a[1])); - } - - function ring(ring) { - var i = -1, - n = ring.length, - a, - b = ring[n - 1], - area = 0; - - while (++i < n) { - a = b; - b = ring[i]; - area += a[0] * b[1] - a[1] * b[0]; - } - - return area / 2; - } - - function merge(topology) { - return object(topology, mergeArcs.apply(this, arguments)); - } - - function mergeArcs(topology, objects) { - var polygonsByArc = {}, - polygons = [], - components = []; - - objects.forEach(function(o) { - if (o.type === "Polygon") register(o.arcs); - else if (o.type === "MultiPolygon") o.arcs.forEach(register); - }); - - function register(polygon) { - polygon.forEach(function(ring$$) { - ring$$.forEach(function(arc) { - (polygonsByArc[arc = arc < 0 ? ~arc : arc] || (polygonsByArc[arc] = [])).push(polygon); - }); - }); - polygons.push(polygon); - } - - function area(ring$$) { - return Math.abs(ring(object(topology, {type: "Polygon", arcs: [ring$$]}).coordinates[0])); - } - - polygons.forEach(function(polygon) { - if (!polygon._) { - var component = [], - neighbors = [polygon]; - polygon._ = 1; - components.push(component); - while (polygon = neighbors.pop()) { - component.push(polygon); - polygon.forEach(function(ring$$) { - ring$$.forEach(function(arc) { - polygonsByArc[arc < 0 ? ~arc : arc].forEach(function(polygon) { - if (!polygon._) { - polygon._ = 1; - neighbors.push(polygon); - } - }); - }); - }); - } - } - }); - - polygons.forEach(function(polygon) { - delete polygon._; - }); - - return { - type: "MultiPolygon", - arcs: components.map(function(polygons) { - var arcs = [], n; - - // Extract the exterior (unique) arcs. - polygons.forEach(function(polygon) { - polygon.forEach(function(ring$$) { - ring$$.forEach(function(arc) { - if (polygonsByArc[arc < 0 ? ~arc : arc].length < 2) { - arcs.push(arc); - } - }); - }); - }); - - // Stitch the arcs into one or more rings. - arcs = stitchArcs(topology, arcs); - - // If more than one ring is returned, - // at most one of these rings can be the exterior; - // choose the one with the greatest absolute area. - if ((n = arcs.length) > 1) { - for (var i = 1, k = area(arcs[0]), ki, t; i < n; ++i) { - if ((ki = area(arcs[i])) > k) { - t = arcs[0], arcs[0] = arcs[i], arcs[i] = t, k = ki; - } - } - } - - return arcs; - }) - }; - } - - function neighbors(objects) { - var indexesByArc = {}, // arc index -> array of object indexes - neighbors = objects.map(function() { return []; }); - - function line(arcs, i) { - arcs.forEach(function(a) { - if (a < 0) a = ~a; - var o = indexesByArc[a]; - if (o) o.push(i); - else indexesByArc[a] = [i]; - }); - } - - function polygon(arcs, i) { - arcs.forEach(function(arc) { line(arc, i); }); - } - - function geometry(o, i) { - if (o.type === "GeometryCollection") o.geometries.forEach(function(o) { geometry(o, i); }); - else if (o.type in geometryType) geometryType[o.type](o.arcs, i); - } - - var geometryType = { - LineString: line, - MultiLineString: polygon, - Polygon: polygon, - MultiPolygon: function(arcs, i) { arcs.forEach(function(arc) { polygon(arc, i); }); } - }; - - objects.forEach(geometry); - - for (var i in indexesByArc) { - for (var indexes = indexesByArc[i], m = indexes.length, j = 0; j < m; ++j) { - for (var k = j + 1; k < m; ++k) { - var ij = indexes[j], ik = indexes[k], n; - if ((n = neighbors[ij])[i = bisect(n, ik)] !== ik) n.splice(i, 0, ik); - if ((n = neighbors[ik])[i = bisect(n, ij)] !== ij) n.splice(i, 0, ij); - } - } - } - - return neighbors; - } - - function compareArea(a, b) { - return a[1][2] - b[1][2]; - } - - function minAreaHeap() { - var heap = {}, - array = [], - size = 0; - - heap.push = function(object) { - up(array[object._ = size] = object, size++); - return size; - }; - - heap.pop = function() { - if (size <= 0) return; - var removed = array[0], object; - if (--size > 0) object = array[size], down(array[object._ = 0] = object, 0); - return removed; - }; - - heap.remove = function(removed) { - var i = removed._, object; - if (array[i] !== removed) return; // invalid request - if (i !== --size) object = array[size], (compareArea(object, removed) < 0 ? up : down)(array[object._ = i] = object, i); - return i; - }; - - function up(object, i) { - while (i > 0) { - var j = ((i + 1) >> 1) - 1, - parent = array[j]; - if (compareArea(object, parent) >= 0) break; - array[parent._ = i] = parent; - array[object._ = i = j] = object; - } - } - - function down(object, i) { - while (true) { - var r = (i + 1) << 1, - l = r - 1, - j = i, - child = array[j]; - if (l < size && compareArea(array[l], child) < 0) child = array[j = l]; - if (r < size && compareArea(array[r], child) < 0) child = array[j = r]; - if (j === i) break; - array[child._ = i] = child; - array[object._ = i = j] = object; - } - } - - return heap; - } - - function presimplify(topology, triangleArea) { - var absolute = transformAbsolute(topology.transform), - relative = transformRelative(topology.transform), - heap = minAreaHeap(); - - if (!triangleArea) triangleArea = cartesianTriangleArea; - - topology.arcs.forEach(function(arc) { - var triangles = [], - maxArea = 0, - triangle, - i, - n, - p; - - // To store each point’s effective area, we create a new array rather than - // extending the passed-in point to workaround a Chrome/V8 bug (getting - // stuck in smi mode). For midpoints, the initial effective area of - // Infinity will be computed in the next step. - for (i = 0, n = arc.length; i < n; ++i) { - p = arc[i]; - absolute(arc[i] = [p[0], p[1], Infinity], i); - } - - for (i = 1, n = arc.length - 1; i < n; ++i) { - triangle = arc.slice(i - 1, i + 2); - triangle[1][2] = triangleArea(triangle); - triangles.push(triangle); - heap.push(triangle); - } - - for (i = 0, n = triangles.length; i < n; ++i) { - triangle = triangles[i]; - triangle.previous = triangles[i - 1]; - triangle.next = triangles[i + 1]; - } - - while (triangle = heap.pop()) { - var previous = triangle.previous, - next = triangle.next; - - // If the area of the current point is less than that of the previous point - // to be eliminated, use the latter's area instead. This ensures that the - // current point cannot be eliminated without eliminating previously- - // eliminated points. - if (triangle[1][2] < maxArea) triangle[1][2] = maxArea; - else maxArea = triangle[1][2]; - - if (previous) { - previous.next = next; - previous[2] = triangle[2]; - update(previous); - } - - if (next) { - next.previous = previous; - next[0] = triangle[0]; - update(next); - } - } - - arc.forEach(relative); - }); - - function update(triangle) { - heap.remove(triangle); - triangle[1][2] = triangleArea(triangle); - heap.push(triangle); - } - - return topology; - } - - var version = "1.6.26"; - - exports.version = version; - exports.mesh = mesh; - exports.meshArcs = meshArcs; - exports.merge = merge; - exports.mergeArcs = mergeArcs; - exports.feature = feature; - exports.neighbors = neighbors; - exports.presimplify = presimplify; - -})); -},{}],11:[function(require,module,exports){ -/*eslint-disable no-cond-assign */ -module.exports = parse; -module.exports.parse = parse; -module.exports.stringify = stringify; - -var numberRegexp = /[-+]?([0-9]*\.[0-9]+|[0-9]+)([eE][-+]?[0-9]+)?/; -// Matches sequences like '100 100' or '100 100 100'. -var tuples = new RegExp('^' + numberRegexp.source + '(\\s' + numberRegexp.source + '){1,}'); - -/* - * Parse WKT and return GeoJSON. - * - * @param {string} _ A WKT geometry - * @return {?Object} A GeoJSON geometry object - */ -function parse (input) { - var parts = input.split(';'); - var _ = parts.pop(); - var srid = (parts.shift() || '').split('=').pop(); - - var i = 0; - - function $ (re) { - var match = _.substring(i).match(re); - if (!match) return null; - else { - i += match[0].length; - return match[0]; - } - } - - function crs (obj) { - if (obj && srid.match(/\d+/)) { - obj.crs = { - type: 'name', - properties: { - name: 'urn:ogc:def:crs:EPSG::' + srid - } - }; - } - - return obj; - } - - function white () { $(/^\s*/); } - - function multicoords () { - white(); - var depth = 0; - var rings = []; - var stack = [rings]; - var pointer = rings; - var elem; - - while (elem = - $(/^(\()/) || - $(/^(\))/) || - $(/^(\,)/) || - $(tuples)) { - if (elem === '(') { - stack.push(pointer); - pointer = []; - stack[stack.length - 1].push(pointer); - depth++; - } else if (elem === ')') { - // For the case: Polygon(), ... - if (pointer.length === 0) return null; - - pointer = stack.pop(); - // the stack was empty, input was malformed - if (!pointer) return null; - depth--; - if (depth === 0) break; - } else if (elem === ',') { - pointer = []; - stack[stack.length - 1].push(pointer); - } else if (!elem.split(/\s/g).some(isNaN)) { - Array.prototype.push.apply(pointer, elem.split(/\s/g).map(parseFloat)); - } else { - return null; - } - white(); - } - - if (depth !== 0) return null; - - return rings; - } - - function coords () { - var list = []; - var item; - var pt; - while (pt = - $(tuples) || - $(/^(\,)/)) { - if (pt === ',') { - list.push(item); - item = []; - } else if (!pt.split(/\s/g).some(isNaN)) { - if (!item) item = []; - Array.prototype.push.apply(item, pt.split(/\s/g).map(parseFloat)); - } - white(); - } - - if (item) list.push(item); - else return null; - - return list.length ? list : null; - } - - function point () { - if (!$(/^(point)/i)) return null; - white(); - if (!$(/^(\()/)) return null; - var c = coords(); - if (!c) return null; - white(); - if (!$(/^(\))/)) return null; - return { - type: 'Point', - coordinates: c[0] - }; - } - - function multipoint () { - if (!$(/^(multipoint)/i)) return null; - white(); - var newCoordsFormat = _ - .substring(_.indexOf('(') + 1, _.length - 1) - .replace(/\(/g, '') - .replace(/\)/g, ''); - _ = 'MULTIPOINT (' + newCoordsFormat + ')'; - var c = multicoords(); - if (!c) return null; - white(); - return { - type: 'MultiPoint', - coordinates: c - }; - } - - function multilinestring () { - if (!$(/^(multilinestring)/i)) return null; - white(); - var c = multicoords(); - if (!c) return null; - white(); - return { - type: 'MultiLineString', - coordinates: c - }; - } - - function linestring () { - if (!$(/^(linestring)/i)) return null; - white(); - if (!$(/^(\()/)) return null; - var c = coords(); - if (!c) return null; - if (!$(/^(\))/)) return null; - return { - type: 'LineString', - coordinates: c - }; - } - - function polygon () { - if (!$(/^(polygon)/i)) return null; - white(); - var c = multicoords(); - if (!c) return null; - return { - type: 'Polygon', - coordinates: c - }; - } - - function multipolygon () { - if (!$(/^(multipolygon)/i)) return null; - white(); - var c = multicoords(); - if (!c) return null; - return { - type: 'MultiPolygon', - coordinates: c - }; - } - - function geometrycollection () { - var geometries = []; - var geometry; - - if (!$(/^(geometrycollection)/i)) return null; - white(); - - if (!$(/^(\()/)) return null; - while (geometry = root()) { - geometries.push(geometry); - white(); - $(/^(\,)/); - white(); - } - if (!$(/^(\))/)) return null; - - return { - type: 'GeometryCollection', - geometries: geometries - }; - } - - function root () { - return point() || - linestring() || - polygon() || - multipoint() || - multilinestring() || - multipolygon() || - geometrycollection(); - } - - return crs(root()); -} - -/** - * Stringifies a GeoJSON object into WKT - */ -function stringify (gj) { - if (gj.type === 'Feature') { - gj = gj.geometry; - } - - function pairWKT (c) { - return c.join(' '); - } - - function ringWKT (r) { - return r.map(pairWKT).join(', '); - } - - function ringsWKT (r) { - return r.map(ringWKT).map(wrapParens).join(', '); - } - - function multiRingsWKT (r) { - return r.map(ringsWKT).map(wrapParens).join(', '); - } - - function wrapParens (s) { return '(' + s + ')'; } - - switch (gj.type) { - case 'Point': - return 'POINT (' + pairWKT(gj.coordinates) + ')'; - case 'LineString': - return 'LINESTRING (' + ringWKT(gj.coordinates) + ')'; - case 'Polygon': - return 'POLYGON (' + ringsWKT(gj.coordinates) + ')'; - case 'MultiPoint': - return 'MULTIPOINT (' + ringWKT(gj.coordinates) + ')'; - case 'MultiPolygon': - return 'MULTIPOLYGON (' + multiRingsWKT(gj.coordinates) + ')'; - case 'MultiLineString': - return 'MULTILINESTRING (' + ringsWKT(gj.coordinates) + ')'; - case 'GeometryCollection': - return 'GEOMETRYCOLLECTION (' + gj.geometries.map(stringify).join(', ') + ')'; - default: - throw new Error('stringify requires a valid GeoJSON Feature or geometry object as input'); - } -} - -},{}]},{},[1])(1) -}); \ No newline at end of file diff --git a/inst/htmlwidgets/lib/leaflet-omnivore/leaflet-omnivore.min.js b/inst/htmlwidgets/lib/leaflet-omnivore/leaflet-omnivore.min.js index aaa8c82b2..5c5728252 100644 --- a/inst/htmlwidgets/lib/leaflet-omnivore/leaflet-omnivore.min.js +++ b/inst/htmlwidgets/lib/leaflet-omnivore/leaflet-omnivore.min.js @@ -1 +1 @@ -!function(r){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.omnivore=r()}}(function(){var r;return function r(e,t,n){function o(u,a){if(!t[u]){if(!e[u]){var s="function"==typeof require&&require;if(!a&&s)return s(u,!0);if(i)return i(u,!0);var f=new Error("Cannot find module '"+u+"'");throw f.code="MODULE_NOT_FOUND",f}var c=t[u]={exports:{}};e[u][0].call(c.exports,function(r){var t=e[u][1][r];return o(t?t:r)},c,c.exports,r,e,t,n)}return t[u].exports}for(var i="function"==typeof require&&require,u=0;u1)for(var t=1;t=200&&r<300||304===r}function o(){void 0===a.status||n(a.status)?e.call(a,null,a):e.call(a,a,null)}var i=!1;if("undefined"==typeof window.XMLHttpRequest)return e(Error("Browser not supported"));if("undefined"==typeof t){var u=r.match(/^\s*https?:\/\/[^\/]*/);t=u&&u[0]!==location.protocol+"//"+location.hostname+(location.port?":"+location.port:"")}var a=new window.XMLHttpRequest;if(t&&!("withCredentials"in a)){a=new window.XDomainRequest;var s=e;e=function(){if(i)s.apply(this,arguments);else{var r=this,e=arguments;setTimeout(function(){s.apply(r,e)},0)}}}return"onload"in a?a.onload=o:a.onreadystatechange=function(){4===a.readyState&&o()},a.onerror=function(r){e.call(this,r||!0,null),e=function(){}},a.onprogress=function(){},a.ontimeout=function(r){e.call(this,r,null),e=function(){}},a.onabort=function(r){e.call(this,r,null),e=function(){}},a.open("GET",r,!0),a.send(null),i=!0,a}"undefined"!=typeof e&&(e.exports=n)},{}],5:[function(r,e,t){"use strict";function n(r,e){var t,n,o;for(var i in r)n=i.match(e),n&&(!t||n[0].length/i.length>o)&&(o=n[0].length/i.length,t=i);return t}function o(r){return n(r,m)}function i(r){return n(r,y)}function u(r){return!!r.match(m)}function a(r){return!!r.match(y)}function s(r){return"object"==typeof r?Object.keys(r).length:0}function f(r){var e=[",",";","\t","|"],t=[];return e.forEach(function(e){var n=d.dsvFormat(e).parse(r);if(n.length>=1){for(var o=s(n[0]),i=0;i=s)return u;if(o)return o=!1,i;var e,t=f;if(34===r.charCodeAt(t)){for(var n=t;n++=0?0:1],o=Math.abs(r),i=Math.floor(o),u=o-i,a=60*u,s=Math.floor(a),f=Math.floor(60*(a-s));return{whole:i,minutes:s,seconds:f,dir:n}}function a(r,e,t){if(e||(e="NSEW"),"string"!=typeof r)return{val:null,regex:t};t=t||/[\s\,]*([\-|\—|\―]?[0-9.]+)°? *(?:([0-9.]+)['’′‘] *)?(?:([0-9.]+)(?:''|"|”|″) *)?([NSEW])?/gi;var n=t.exec(r);return n?n[4]&&e.indexOf(n[4])===-1?{val:null,regex:t}:{val:((n[1]?parseFloat(n[1]):0)+(n[2]?parseFloat(n[2])/60:0)+(n[3]?parseFloat(n[3])/3600:0))*(n[4]&&"S"===n[4]||"W"===n[4]?-1:1),regex:t,raw:n[0],dim:n[4]}:{val:null,regex:t}}function s(r,e){r=r.trim();var t=a(r,e);if(null===t.val)return null;var n=a(r,e,t.regex);return null===n.val?null:t.raw+n.raw!==r?null:t.dim?f(t.val,n.val,t.dim):[t.val,n.val]}function f(r,e,t){return"N"===t||"S"===t?[r,e]:"W"===t||"E"===t?[e,r]:void 0}e.exports=n,e.exports.pair=s,e.exports.format=i,e.exports.formatPair=o,e.exports.coordToDMS=u},{}],8:[function(r,e,t){"use strict";function n(r,e){r=Math.round(r*e),r<<=1,r<0&&(r=~r);for(var t="";r>=32;)t+=String.fromCharCode((32|31&r)+63),r>>=5;return t+=String.fromCharCode(r+63)}function o(r){for(var e=[],t=0;t=32);t=1&f?~(f>>1):f>>1,s=f=0;do c=r.charCodeAt(o++)-63,f|=(31&c)<=32);n=1&f?~(f>>1):f>>1,i+=t,u+=n,a.push([i/l,u/l])}return a},i.encode=function(r,e){if(!r.length)return"";for(var t=Math.pow(10,e||5),o=n(r[0][0],t)+n(r[0][1],t),i=1;i>>1;r[o]1){var s,c=[],l={LineString:o,MultiLineString:i,Polygon:i,MultiPolygon:function(r){r.forEach(i)}};u(e),c.forEach(arguments.length<3?function(r){a.push(r[0].i)}:function(r){t(r[0].g,r[r.length-1].g)&&a.push(r[0].i)})}else for(var p=0,h=r.arcs.length;p1)for(var u,a,s=1,c=n(i[0]);sc&&(a=i[0],i[0]=i[s],i[s]=a,c=u);return i})}}function v(r){function e(r,e){r.forEach(function(r){r<0&&(r=~r);var t=o[r];t?t.push(e):o[r]=[e]})}function t(r,t){r.forEach(function(r){e(r,t)})}function n(r,e){"GeometryCollection"===r.type?r.geometries.forEach(function(r){n(r,e)}):r.type in a&&a[r.type](r.arcs,e)}var o={},u=r.map(function(){return[]}),a={LineString:e,MultiLineString:t,Polygon:t,MultiPolygon:function(r,e){r.forEach(function(r){t(r,e)})}};r.forEach(n);for(var s in o)for(var f=o[s],c=f.length,l=0;l0;){var t=(e+1>>1)-1,o=n[t];if(m(r,o)>=0)break;n[o._=e]=o,n[r._=e=t]=r}}function e(r,e){for(;;){var t=e+1<<1,i=t-1,u=e,a=n[u];if(i0&&(r=n[o],e(n[r._=0]=r,0)),t}},t.remove=function(t){var i,u=t._;if(n[u]===t)return u!==--o&&(i=n[o],(m(i,t)<0?r:e)(n[i._=u]=i,u)),u},t}function x(r,e){function o(r){a.remove(r),r[1][2]=e(r),a.push(r)}var i=t(r.transform),u=n(r.transform),a=y();return e||(e=p),r.arcs.forEach(function(r){var t,n,s,f,c=[],l=0;for(n=0,s=r.length;n0)){var r=t.shift();r()}},!0),function(e){t.push(e),window.postMessage("process-tick","*")}):function(e){setTimeout(e,0)}}(),t.title="browser",t.browser=!0,t.env={},t.argv=[],t.on=r,t.addListener=r,t.once=r,t.off=r,t.removeListener=r,t.removeAllListeners=r,t.emit=r,t.binding=function(){throw new Error("process.binding is not supported")},t.cwd=function(){return"/"},t.chdir=function(){throw new Error("process.chdir is not supported")}},{}],5:[function(e,n){function r(e,n,r){function t(e){return e>=200&&300>e||304===e}function o(){void 0===a.status||t(a.status)?n.call(a,null,a):n.call(a,a,null)}var i=!1;if("undefined"==typeof window.XMLHttpRequest)return n(Error("Browser not supported"));if("undefined"==typeof r){var u=e.match(/^\s*https?:\/\/[^\/]*/);r=u&&u[0]!==location.protocol+"//"+location.domain+(location.port?":"+location.port:"")}var a=new window.XMLHttpRequest;if(r&&!("withCredentials"in a)){a=new window.XDomainRequest;var s=n;n=function(){if(i)s.apply(this,arguments);else{var e=this,n=arguments;setTimeout(function(){s.apply(e,n)},0)}}}return"onload"in a?a.onload=o:a.onreadystatechange=function(){4===a.readyState&&o()},a.onerror=function(e){n.call(this,e||!0,null),n=function(){}},a.onprogress=function(){},a.ontimeout=function(e){n.call(this,e,null),n=function(){}},a.onabort=function(e){n.call(this,e,null),n=function(){}},a.open("GET",e,!0),a.send(null),i=!0,a}"undefined"!=typeof n&&(n.exports=r)},{}],6:[function(e,n){function r(e){return!!e.match(/(Lat)(itude)?/gi)}function t(e){return!!e.match(/(L)(on|ng)(gitude)?/i)}function o(e){return"object"==typeof e?Object.keys(e).length:0}function i(e){var n=[",",";"," ","|"],r=[];return n.forEach(function(n){var t=c(n).parse(e);if(t.length>=1){for(var i=o(t[0]),u=0;u= N) return EOF; // special case: end of file\n if (eol) return eol = false, EOL; // special case: end of line\n\n // special case: quotes\n var j = I;\n if (text.charCodeAt(j) === 34) {\n var i = j;\n while (i++ < N) {\n if (text.charCodeAt(i) === 34) {\n if (text.charCodeAt(i + 1) !== 34) break;\n ++i;\n }\n }\n I = i + 2;\n var c = text.charCodeAt(i + 1);\n if (c === 13) {\n eol = true;\n if (text.charCodeAt(i + 2) === 10) ++I;\n } else if (c === 10) {\n eol = true;\n }\n return text.substring(j + 1, i).replace(/""/g, "\\"");\n }\n\n // common case: find next delimiter or newline\n while (I < N) {\n var c = text.charCodeAt(I++), k = 1;\n if (c === 10) eol = true; // \\n\n else if (c === 13) { eol = true; if (text.charCodeAt(I) === 10) ++I, ++k; } // \\r|\\r\\n\n else if (c !== delimiterCode) continue;\n return text.substring(j, I - k);\n }\n\n // special case: last token before EOF\n return text.substring(j);\n }\n\n while ((t = token()) !== EOF) {\n var a = [];\n while (t !== EOL && t !== EOF) {\n a.push(t);\n t = token();\n }\n if (f && !(a = f(a, n++))) continue;\n rows.push(a);\n }\n\n return rows;\n };\n\n dsv.format = function(rows) {\n if (Array.isArray(rows[0])) return dsv.formatRows(rows); // deprecated; use formatRows\n var fieldSet = {}, fields = [];\n\n // Compute unique fields in order of discovery.\n rows.forEach(function(row) {\n for (var field in row) {\n if (!(field in fieldSet)) {\n fields.push(fieldSet[field] = field);\n }\n }\n });\n\n return [fields.map(formatValue).join(delimiter)].concat(rows.map(function(row) {\n return fields.map(function(field) {\n return formatValue(row[field]);\n }).join(delimiter);\n })).join("\\n");\n };\n\n dsv.formatRows = function(rows) {\n return rows.map(formatRow).join("\\n");\n };\n\n function formatRow(row) {\n return row.map(formatValue).join(delimiter);\n }\n\n function formatValue(text) {\n return reFormat.test(text) ? "\\"" + text.replace(/\\"/g, "\\"\\"") + "\\"" : text;\n }\n\n return dsv;\n}\n;return dsv')()},{fs:2}],8:[function(e,n){n.exports=function(e,n){if(n||(n="NSEW"),"string"!=typeof e)return null;var r=/^([0-9.]+)°? *(?:([0-9.]+)['’′‘] *)?(?:([0-9.]+)(?:''|"|”|″) *)?([NSEW])?/,t=e.match(r);return t?t[4]&&-1===n.indexOf(t[4])?null:((t[1]?parseFloat(t[1]):0)+(t[2]?parseFloat(t[2])/60:0)+(t[3]?parseFloat(t[3])/3600:0))*(t[4]&&"S"===t[4]||"W"===t[4]?-1:1):null}},{}],9:[function(e,n){function r(e,n){e=Math.round(e*n),e<<=1,0>e&&(e=~e);for(var r="";e>=32;)r+=String.fromCharCode((32|31&e)+63),e>>=5;return r+=String.fromCharCode(e+63)}var t={};t.decode=function(e,n){for(var r,t,o=0,i=0,u=0,a=[],s=0,f=0,c=null,l=Math.pow(10,n||5);o=32);r=1&f?~(f>>1):f>>1,s=f=0;do c=e.charCodeAt(o++)-63,f|=(31&c)<=32);t=1&f?~(f>>1):f>>1,i+=r,u+=t,a.push([i/l,u/l])}return a},t.encode=function(e,n){if(!e.length)return"";for(var t=Math.pow(10,n||5),o=r(e[0][0],t)+r(e[0][1],t),i=1;iu)){for(var a=0;u>a;a++){var s=g(r[a]);t.push(s.coordinates),s.time&&i.push(s.time)}return{line:t,times:i}}}function r(e){for(var r,t=o(e,"trkseg"),i=[],a=[],s=0;sn?~n:n],o=t[0];return e.transform?(r=[0,0],t.forEach(function(e){r[0]+=e[0],r[1]+=e[1]})):r=t[t.length-1],0>n?[r,o]:[o,r]}function t(e,n){for(var r in e){var t=e[r];delete n[t.start],delete t.start,delete t.end,t.forEach(function(e){o[0>e?~e:e]=1}),a.push(t)}}var o={},i={},u={},a=[],s=-1;return n.forEach(function(r,t){var o,i=e.arcs[0>r?~r:r];i.length<3&&!i[1][0]&&!i[1][1]&&(o=n[++s],n[s]=r,n[t]=o)}),n.forEach(function(e){var n,t,o=r(e),a=o[0],s=o[1];if(n=u[a])if(delete u[n.end],n.push(e),n.end=s,t=i[s]){delete i[t.start];var f=t===n?n:n.concat(t);i[f.start=n.start]=u[f.end=t.end]=f}else i[n.start]=u[n.end]=n;else if(n=i[s])if(delete i[n.start],n.unshift(e),n.start=a,t=u[a]){delete u[t.end];var c=t===n?n:t.concat(n);i[c.start=t.start]=u[c.end=n.end]=c}else i[n.start]=u[n.end]=n;else n=[e],i[n.start=a]=u[n.end=s]=n}),t(u,i),t(i,u),n.forEach(function(e){o[0>e?~e:e]||a.push([e])}),a}function o(e,n,t){function o(e){var n=0>e?~e:e;(c[n]||(c[n]=[])).push({i:e,g:f})}function i(e){e.forEach(o)}function u(e){e.forEach(i)}function a(e){"GeometryCollection"===e.type?e.geometries.forEach(a):e.type in l&&(f=e,l[e.type](e.arcs))}var s=[];if(arguments.length>1){var f,c=[],l={LineString:i,MultiLineString:u,Polygon:u,MultiPolygon:function(e){e.forEach(u)}};a(n),c.forEach(arguments.length<3?function(e){s.push(e[0].i)}:function(e){t(e[0].g,e[e.length-1].g)&&s.push(e[0].i)})}else for(var p=0,d=e.arcs.length;d>p;++p)s.push(p);return{type:"MultiLineString",arcs:r(e,s)}}function i(e,t){function o(e){e.forEach(function(n){n.forEach(function(n){(u[n=0>n?~n:n]||(u[n]=[])).push(e)})}),a.push(e)}function i(n){return d(s(e,{type:"Polygon",arcs:[n]}).coordinates[0])>0}var u={},a=[],f=[];return t.forEach(function(e){"Polygon"===e.type?o(e.arcs):"MultiPolygon"===e.type&&e.arcs.forEach(o)}),a.forEach(function(e){if(!e._){var n=[],r=[e];for(e._=1,f.push(n);e=r.pop();)n.push(e),e.forEach(function(e){e.forEach(function(e){u[0>e?~e:e].forEach(function(e){e._||(e._=1,r.push(e))})})})}}),a.forEach(function(e){delete e._}),{type:"MultiPolygon",arcs:f.map(function(t){var o=[];if(t.forEach(function(e){e.forEach(function(e){e.forEach(function(e){u[0>e?~e:e].length<2&&o.push(e)})})}),o=r(e,o),(n=o.length)>1)for(var a,s=i(t[0][0]),f=0;fe?~e:e],o=0,i=t.length;i>o;++o)n.push(r=t[o].slice()),s(r,o);0>e&&f(n,i)}function t(e){return e=e.slice(),s(e,0),e}function o(e){for(var n=[],t=0,o=e.length;o>t;++t)r(e[t],n);return n.length<2&&n.push(n[0].slice()),n}function i(e){for(var n=o(e);n.length<4;)n.push(n[0].slice());return n}function u(e){return e.map(i)}function a(e){var n=e.type;return"GeometryCollection"===n?{type:n,geometries:e.geometries.map(a)}:n in l?{type:n,coordinates:l[n](e)}:null}var s=m(e.transform),c=e.arcs,l={Point:function(e){return t(e.coordinates)},MultiPoint:function(e){return e.coordinates.map(t)},LineString:function(e){return o(e.arcs)},MultiLineString:function(e){return e.arcs.map(o)},Polygon:function(e){return u(e.arcs)},MultiPolygon:function(e){return e.arcs.map(u)}};return a(n)}function f(e,n){for(var r,t=e.length,o=t-n;o<--t;)r=e[o],e[o++]=e[t],e[t]=r}function c(e,n){for(var r=0,t=e.length;t>r;){var o=r+t>>>1;e[o]e&&(e=~e);var r=o[e];r?r.push(n):o[e]=[n]})}function r(e,r){e.forEach(function(e){n(e,r)})}function t(e,n){"GeometryCollection"===e.type?e.geometries.forEach(function(e){t(e,n)}):e.type in u&&u[e.type](e.arcs,n)}var o={},i=e.map(function(){return[]}),u={LineString:n,MultiLineString:r,Polygon:r,MultiPolygon:function(e,n){e.forEach(function(e){r(e,n)})}};e.forEach(t);for(var a in o)for(var s=o[a],f=s.length,l=0;f>l;++l)for(var p=l+1;f>p;++p){var d,g=s[l],h=s[p];(d=i[g])[a=c(d,h)]!==h&&d.splice(a,0,h),(d=i[h])[a=c(d,g)]!==g&&d.splice(a,0,g)}return i}function p(e,n){function r(e){u.remove(e),e[1][2]=n(e),u.push(e)}var t,o=m(e.transform),i=y(e.transform),u=v(),a=0;for(n||(n=g),e.arcs.forEach(function(e){var r=[];e.forEach(o);for(var i=1,a=e.length-1;a>i;++i)t=e.slice(i-1,i+2),t[1][2]=n(t),r.push(t),u.push(t);e[0][2]=e[a][2]=1/0;for(var i=0,a=r.length;a>i;++i)t=r[i],t.previous=r[i-1],t.next=r[i+1]});t=u.pop();){var s=t.previous,f=t.next;t[1][2]0;){var r=(n+1>>1)-1,o=t[r];if(h(e,o)>=0)break;t[o._=n]=o,t[e._=n=r]=e}}function n(e,n){for(;;){var r=n+1<<1,i=r-1,u=n,a=t[u];if(o>i&&h(t[i],a)<0&&(a=t[u=i]),o>r&&h(t[r],a)<0&&(a=t[u=r]),u===n)break;t[a._=n]=a,t[e._=n=u]=e}}var r={},t=[],o=0;return r.push=function(n){return e(t[n._=o]=n,o++),o},r.pop=function(){if(!(0>=o)){var e,r=t[0];return--o>0&&(e=t[o],n(t[e._=0]=e,0)),r}},r.remove=function(r){var i,u=r._;if(t[u]===r)return u!==--o&&(i=t[o],(h(i,r)<0?e:n)(t[i._=u]=i,u)),u},r}function m(e){if(!e)return w;var n,r,t=e.scale[0],o=e.scale[1],i=e.translate[0],u=e.translate[1];return function(e,a){a||(n=r=0),e[0]=(n+=e[0])*t+i,e[1]=(r+=e[1])*o+u}}function y(e){if(!e)return w;var n,r,t=e.scale[0],o=e.scale[1],i=e.translate[0],u=e.translate[1];return function(e,a){a||(n=r=0);var s=(e[0]-i)/t|0,f=(e[1]-u)/o|0;e[0]=s-n,e[1]=f-r,n=s,r=f}}function w(){}var x={version:"1.6.8",mesh:function(e){return s(e,o.apply(this,arguments))},meshArcs:o,merge:function(e){return s(e,i.apply(this,arguments))},mergeArcs:i,feature:u,neighbors:l,presimplify:p};"function"==typeof e&&e.amd?e(x):"object"==typeof t&&t.exports?t.exports=x:this.topojson=x}()},{}],12:[function(e,n){function r(e){function n(n){var r=e.substring(m).match(n);return r?(m+=r[0].length,r[0]):null}function r(e){return e&&v.match(/\d+/)&&(e.crs={type:"name",properties:{name:"urn:ogc:def:crs:EPSG::"+v}}),e}function t(){n(/^\s*/)}function i(){t();for(var e,r=0,i=[],u=[i],a=i;e=n(/^(\()/)||n(/^(\))/)||n(/^(\,)/)||n(o);){if("("==e)u.push(a),a=[],u[u.length-1].push(a),r++;else if(")"==e){if(a=u.pop(),!a)return;if(r--,0===r)break}else if(","===e)a=[],u[u.length-1].push(a);else{if(isNaN(parseFloat(e)))return null;a.push(parseFloat(e))}t()}return 0!==r?null:i}function u(){for(var e,r,i=[];r=n(o)||n(/^(\,)/);)","==r?(i.push(e),e=[]):(e||(e=[]),e.push(parseFloat(r))),t();return e&&i.push(e),i.length?i:null}function a(){if(!n(/^(point)/i))return null;if(t(),!n(/^(\()/))return null;var e=u();return e?(t(),n(/^(\))/)?{type:"Point",coordinates:e[0]}:null):null}function s(){if(!n(/^(multipoint)/i))return null;t();var e=i();return e?(t(),{type:"MultiPoint",coordinates:e}):null}function f(){if(!n(/^(multilinestring)/i))return null;t();var e=i();return e?(t(),{type:"MultiLineString",coordinates:e}):null}function c(){if(!n(/^(linestring)/i))return null;if(t(),!n(/^(\()/))return null;var e=u();return e&&n(/^(\))/)?{type:"LineString",coordinates:e}:null}function l(){return n(/^(polygon)/i)?(t(),{type:"Polygon",coordinates:i()}):null}function p(){return n(/^(multipolygon)/i)?(t(),{type:"MultiPolygon",coordinates:i()}):null}function d(){var e,r=[];if(!n(/^(geometrycollection)/i))return null;if(t(),!n(/^(\()/))return null;for(;e=g();)r.push(e),t(),n(/^(\,)/),t();return n(/^(\))/)?{type:"GeometryCollection",geometries:r}:null}function g(){return a()||c()||l()||s()||f()||p()||d()}var h=e.split(";"),e=h.pop(),v=(h.shift()||"").split("=").pop(),m=0;return r(g())}function t(e){function n(e){return 2===e.length?e[0]+" "+e[1]:3===e.length?e[0]+" "+e[1]+" "+e[2]:void 0}function r(e){return e.map(n).join(", ")}function o(e){return e.map(r).map(u).join(", ")}function i(e){return e.map(o).map(u).join(", ")}function u(e){return"("+e+")"}switch("Feature"===e.type&&(e=e.geometry),e.type){case"Point":return"POINT ("+n(e.coordinates)+")";case"LineString":return"LINESTRING ("+r(e.coordinates)+")";case"Polygon":return"POLYGON ("+o(e.coordinates)+")";case"MultiPoint":return"MULTIPOINT ("+r(e.coordinates)+")";case"MultiPolygon":return"MULTIPOLYGON ("+i(e.coordinates)+")";case"MultiLineString":return"MULTILINESTRING ("+o(e.coordinates)+")";case"GeometryCollection":return"GEOMETRYCOLLECTION ("+e.geometries.map(t).join(", ")+")";default:throw new Error("stringify requires a valid GeoJSON Feature or geometry object as input")}}n.exports=r,n.exports.parse=r,n.exports.stringify=t;var o=/^[-+]?([0-9]*\.[0-9]+|[0-9]+)([eE][-+]?[0-9]+)?/},{}]},{},[1])(1)}); \ No newline at end of file diff --git a/inst/htmlwidgets/lib/leaflet-providers/bower.json b/inst/htmlwidgets/lib/leaflet-providers/bower.json index 744fd4c91..670abf605 100644 --- a/inst/htmlwidgets/lib/leaflet-providers/bower.json +++ b/inst/htmlwidgets/lib/leaflet-providers/bower.json @@ -1,6 +1,6 @@ { "name": "leaflet-providers", - "version": "1.1.15", + "version": "1.1.17", "homepage": "https://github.com/leaflet-extras/leaflet-providers", "description": "An extension to Leaflet that contains configurations for various free tile providers.", "dependencies": { diff --git a/inst/htmlwidgets/lib/leaflet-providers/leaflet-providers.js b/inst/htmlwidgets/lib/leaflet-providers/leaflet-providers.js index 22e2cbdbd..1b6a28dbe 100644 --- a/inst/htmlwidgets/lib/leaflet-providers/leaflet-providers.js +++ b/inst/htmlwidgets/lib/leaflet-providers/leaflet-providers.js @@ -50,11 +50,6 @@ }; } - var forceHTTP = window.location.protocol === 'file:' || provider.options.forceHTTP; - if (provider.url.indexOf('//') === 0 && forceHTTP) { - provider.url = 'http:' + provider.url; - } - // If retina option is set if (provider.options.retina) { // Check retina screen @@ -95,7 +90,7 @@ L.TileLayer.Provider.providers = { OpenStreetMap: { - url: '//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', + url: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', options: { maxZoom: 19, attribution: @@ -110,64 +105,70 @@ } }, DE: { - url: 'http://{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png', + url: 'https://{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png', options: { maxZoom: 18 } }, France: { - url: '//{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png', + url: 'https://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png', options: { maxZoom: 20, attribution: '© Openstreetmap France | {attribution.OpenStreetMap}' } }, HOT: { - url: '//{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png', + url: 'https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png', options: { attribution: '{attribution.OpenStreetMap}, Tiles courtesy of Humanitarian OpenStreetMap Team' } + }, + BZH: { + url: 'http://tile.openstreetmap.bzh/br/{z}/{x}/{y}.png', + options: { + attribution: '{attribution.OpenStreetMap}, Tiles courtesy of Breton OpenStreetMap Team', + bounds: [[46.2, -5.5], [50, 0.7]] + } } } }, OpenSeaMap: { - url: 'http://tiles.openseamap.org/seamark/{z}/{x}/{y}.png', + url: 'https://tiles.openseamap.org/seamark/{z}/{x}/{y}.png', options: { attribution: 'Map data: © OpenSeaMap contributors' } }, OpenTopoMap: { - url: '//{s}.tile.opentopomap.org/{z}/{x}/{y}.png', + url: 'https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png', options: { maxZoom: 17, attribution: 'Map data: {attribution.OpenStreetMap}, SRTM | Map style: © OpenTopoMap (CC-BY-SA)' } }, Thunderforest: { - url: '//{s}.tile.thunderforest.com/{variant}/{z}/{x}/{y}.png', + url: 'https://{s}.tile.thunderforest.com/{variant}/{z}/{x}/{y}.png?apikey={apikey}', options: { attribution: '© Thunderforest, {attribution.OpenStreetMap}', - variant: 'cycle' + variant: 'cycle', + apikey: '', + maxZoom: 22 }, variants: { OpenCycleMap: 'cycle', Transport: { options: { - variant: 'transport', - maxZoom: 19 + variant: 'transport' } }, TransportDark: { options: { - variant: 'transport-dark', - maxZoom: 19 + variant: 'transport-dark' } }, SpinalMap: { options: { - variant: 'spinal-map', - maxZoom: 11 + variant: 'spinal-map' } }, Landscape: 'landscape', @@ -176,7 +177,7 @@ } }, OpenMapSurfer: { - url: 'http://korona.geog.uni-heidelberg.de/tiles/{variant}/x={x}&y={y}&z={z}', + url: 'https://korona.geog.uni-heidelberg.de/tiles/{variant}/x={x}&y={y}&z={z}', options: { maxZoom: 20, variant: 'roads', @@ -199,8 +200,9 @@ } }, Hydda: { - url: '//{s}.tile.openstreetmap.se/hydda/{variant}/{z}/{x}/{y}.png', + url: 'https://{s}.tile.openstreetmap.se/hydda/{variant}/{z}/{x}/{y}.png', options: { + maxZoom: 18, variant: 'full', attribution: 'Tiles courtesy of OpenStreetMap Sweden — Map data {attribution.OpenStreetMap}' }, @@ -211,16 +213,18 @@ } }, MapBox: { - url: '//api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', + url: 'https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', options: { attribution: 'Imagery from MapBox — ' + 'Map data {attribution.OpenStreetMap}', - subdomains: 'abcd' + subdomains: 'abcd', + id: 'streets', + accessToken: '', } }, Stamen: { - url: '//stamen-tiles-{s}.a.ssl.fastly.net/{variant}/{z}/{x}/{y}.{ext}', + url: 'https://stamen-tiles-{s}.a.ssl.fastly.net/{variant}/{z}/{x}/{y}.{ext}', options: { attribution: 'Map tiles by Stamen Design, ' + @@ -277,7 +281,7 @@ } }, Esri: { - url: '//server.arcgisonline.com/ArcGIS/rest/services/{variant}/MapServer/tile/{z}/{y}/{x}', + url: 'https://server.arcgisonline.com/ArcGIS/rest/services/{variant}/MapServer/tile/{z}/{y}/{x}', options: { variant: 'World_Street_Map', attribution: 'Tiles © Esri' @@ -361,10 +365,11 @@ } }, OpenWeatherMap: { - url: 'http://{s}.tile.openweathermap.org/map/{variant}/{z}/{x}/{y}.png', + url: 'http://{s}.tile.openweathermap.org/map/{variant}/{z}/{x}/{y}.png?appid={apiKey}', options: { maxZoom: 19, attribution: 'Map data © OpenWeatherMap', + apiKey:'', opacity: 0.5 }, variants: { @@ -392,7 +397,7 @@ * envirionments. */ url: - '//{s}.{base}.maps.cit.api.here.com/maptile/2.1/' + + 'https://{s}.{base}.maps.cit.api.here.com/maptile/2.1/' + '{type}/{mapID}/{variant}/{z}/{x}/{y}/{size}/{format}?' + 'app_id={app_id}&app_code={app_code}&lg={language}', options: { @@ -494,7 +499,7 @@ } }, CartoDB: { - url: 'http://{s}.basemaps.cartocdn.com/{variant}/{z}/{x}/{y}.png', + url: 'https://cartodb-basemaps-{s}.global.ssl.fastly.net/{variant}/{z}/{x}/{y}.png', options: { attribution: '{attribution.OpenStreetMap} © CartoDB', subdomains: 'abcd', @@ -528,7 +533,7 @@ } }, BasemapAT: { - url: '//maps{s}.wien.gv.at/basemap/{variant}/normal/google3857/{z}/{y}/{x}.{format}', + url: 'https://maps{s}.wien.gv.at/basemap/{variant}/normal/google3857/{z}/{y}/{x}.{format}', options: { maxZoom: 19, attribution: 'Datenquelle: basemap.at', @@ -538,7 +543,12 @@ variant: 'geolandbasemap' }, variants: { - basemap: 'geolandbasemap', + basemap: { + options: { + maxZoom: 20, // currently only in Vienna + variant: 'geolandbasemap' + } + }, grau: 'bmapgrau', overlay: 'bmapoverlay', highdpi: { @@ -549,14 +559,32 @@ }, orthofoto: { options: { + maxZoom: 20, // currently only in Vienna variant: 'bmaporthofoto30cm', format: 'jpeg' } } } }, + nlmaps: { + url: 'https://geodata.nationaalgeoregister.nl/tiles/service/wmts/{variant}/EPSG:3857/{z}/{x}/{y}.png', + options: { + minZoom: 6, + maxZoom: 19, + bounds: [[50.5, 3.25], [54, 7.6]], + attribution: 'Kaartgegevens © Kadaster' + }, + variants: { + 'standaard': 'brtachtergrondkaart', + 'pastel': 'brtachtergrondkaartpastel', + 'grijs': 'brtachtergrondkaartgrijs', + 'luchtfoto': { + 'url': 'https://geodata.nationaalgeoregister.nl/luchtfoto/rgb/wmts/1.0.0/2016_ortho25/EPSG:3857/{z}/{x}/{y}.png', + } + } + }, NASAGIBS: { - url: '//map1.vis.earthdata.nasa.gov/wmts-webmerc/{variant}/default/{time}/{tilematrixset}{maxZoom}/{z}/{y}/{x}.{format}', + url: 'https://map1.vis.earthdata.nasa.gov/wmts-webmerc/{variant}/default/{time}/{tilematrixset}{maxZoom}/{z}/{y}/{x}.{format}', options: { attribution: 'Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System ' + @@ -620,7 +648,7 @@ // z0-9 - 1:1m // z10-11 - quarter inch (1:253440) // z12-18 - one inch (1:63360) - url: '//nls-{s}.tileserver.com/nls/{z}/{x}/{y}.jpg', + url: 'https://nls-{s}.tileserver.com/nls/{z}/{x}/{y}.jpg', options: { attribution: 'National Library of Scotland Historic Maps', bounds: [[49.6, -12], [61.7, 3]], @@ -628,6 +656,30 @@ maxZoom: 18, subdomains: '0123', } + }, + JusticeMap: { + // Justice Map (http://www.justicemap.org/) + // Visualize race and income data for your community, county and country. + // Includes tools for data journalists, bloggers and community activists. + url: 'http://www.justicemap.org/tile/{size}/{variant}/{z}/{x}/{y}.png', + options: { + attribution: 'Justice Map', + // one of 'county', 'tract', 'block' + size: 'county', + // Bounds for USA, including Alaska and Hawaii + bounds: [[14, -180], [72, -56]] + }, + variants: { + income: 'income', + americanIndian: 'indian', + asian: 'asian', + black: 'black', + hispanic: 'hispanic', + multi: 'multi', + nonWhite: 'nonwhite', + white: 'white', + plurality: 'plural' + } } }; diff --git a/inst/htmlwidgets/lib/leaflet-providers/package.json b/inst/htmlwidgets/lib/leaflet-providers/package.json index f4cbdc36d..6149848f0 100644 --- a/inst/htmlwidgets/lib/leaflet-providers/package.json +++ b/inst/htmlwidgets/lib/leaflet-providers/package.json @@ -1,6 +1,6 @@ { "name": "leaflet-providers", - "version": "1.1.15", + "version": "1.1.17", "description": "An extension to Leaflet that contains configurations for various free tile providers.", "main": "leaflet-providers.js", "repository": { @@ -9,7 +9,7 @@ }, "scripts": { "test": "npm run lint && npm run testsuite", - "testsuite": "mocha-phantomjs tests/index.html", + "testsuite": "phantomjs ./node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js tests/index.html", "lint": "eslint --config .eslintrc leaflet-providers.js index.html preview/*.js preview/*.html tests/*", "min": "uglifyjs leaflet-providers.js -mc -o leaflet-providers.min.js", "release": "mversion patch -m" @@ -26,12 +26,12 @@ ], "devDependencies": { "chai": "^2.3.0", - "eslint": "^2.7.0", - "eslint-plugin-html": "^1.4.0", + "eslint": "^3.16.1", + "eslint-plugin-html": "^2.0.1", "mocha": "^2.2.4", - "mocha-phantomjs": "^3.5.3", + "mocha-phantomjs-core": "^2.0.1", "mversion": "^1.3.0", - "phantomjs": "1.9.7-15", + "phantomjs-prebuilt": "^2.1.4", "uglify-js": "^2.4.15" }, "autoupdate": { diff --git a/inst/htmlwidgets/lib/leaflet-providers/providers.json b/inst/htmlwidgets/lib/leaflet-providers/providers.json index fd13f3635..3a3183587 100644 --- a/inst/htmlwidgets/lib/leaflet-providers/providers.json +++ b/inst/htmlwidgets/lib/leaflet-providers/providers.json @@ -1,504 +1,553 @@ { - "OpenStreetMap": { - "url": "//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", - "options": { - "maxZoom": 19, - "attribution": - "© OpenStreetMap" - }, - "variants": { - "Mapnik": {}, - "BlackAndWhite": { - "url": "http://{s}.tiles.wmflabs.org/bw-mapnik/{z}/{x}/{y}.png", - "options": { - "maxZoom": 18 - } - }, - "DE": { - "url": "http://{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png", - "options": { - "maxZoom": 18 - } - }, - "France": { - "url": "//{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png", - "options": { - "maxZoom": 20, - "attribution": "© Openstreetmap France | {attribution.OpenStreetMap}" - } - }, - "HOT": { - "url": "//{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png", - "options": { - "attribution": "{attribution.OpenStreetMap}, Tiles courtesy of Humanitarian OpenStreetMap Team" - } - } - } - }, - "OpenSeaMap": { - "url": "http://tiles.openseamap.org/seamark/{z}/{x}/{y}.png", - "options": { - "attribution": "Map data: © OpenSeaMap contributors" - } - }, - "OpenTopoMap": { - "url": "//{s}.tile.opentopomap.org/{z}/{x}/{y}.png", - "options": { - "maxZoom": 17, - "attribution": "Map data: {attribution.OpenStreetMap}, SRTM | Map style: © OpenTopoMap (CC-BY-SA)" - } - }, - "Thunderforest": { - "url": "//{s}.tile.thunderforest.com/{variant}/{z}/{x}/{y}.png", - "options": { - "attribution": - "© Thunderforest, {attribution.OpenStreetMap}", - "variant": "cycle" - }, - "variants": { - "OpenCycleMap": "cycle", - "Transport": { - "options": { - "variant": "transport", - "maxZoom": 19 - } - }, - "TransportDark": { - "options": { - "variant": "transport-dark", - "maxZoom": 19 - } - }, - "SpinalMap": { - "options": { - "variant": "spinal-map", - "maxZoom": 11 - } - }, - "Landscape": "landscape", - "Outdoors": "outdoors", - "Pioneer": "pioneer" - } - }, - "OpenMapSurfer": { - "url": "http://korona.geog.uni-heidelberg.de/tiles/{variant}/x={x}&y={y}&z={z}", - "options": { - "maxZoom": 20, - "variant": "roads", - "attribution": "Imagery from GIScience Research Group @ University of Heidelberg — Map data {attribution.OpenStreetMap}" - }, - "variants": { - "Roads": "roads", - "AdminBounds": { - "options": { - "variant": "adminb", - "maxZoom": 19 - } - }, - "Grayscale": { - "options": { - "variant": "roadsg", - "maxZoom": 19 - } - } - } - }, - "Hydda": { - "url": "//{s}.tile.openstreetmap.se/hydda/{variant}/{z}/{x}/{y}.png", - "options": { - "variant": "full", - "attribution": "Tiles courtesy of OpenStreetMap Sweden — Map data {attribution.OpenStreetMap}" - }, - "variants": { - "Full": "full", - "Base": "base", - "RoadsAndLabels": "roads_and_labels" - } - }, - "MapBox": { - "url": "//api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}", - "options": { - "attribution": "Imagery from MapBox — Map data {attribution.OpenStreetMap}", - "subdomains": "abcd" - } - }, - "Stamen": { - "url": "//stamen-tiles-{s}.a.ssl.fastly.net/{variant}/{z}/{x}/{y}.{ext}", - "options": { - "attribution": "Map tiles by Stamen Design, CC BY 3.0 — Map data {attribution.OpenStreetMap}", - "subdomains": "abcd", - "minZoom": 0, - "maxZoom": 20, - "variant": "toner", - "ext": "png" - }, - "variants": { - "Toner": "toner", - "TonerBackground": "toner-background", - "TonerHybrid": "toner-hybrid", - "TonerLines": "toner-lines", - "TonerLabels": "toner-labels", - "TonerLite": "toner-lite", - "Watercolor": { - "options": { - "variant": "watercolor", - "minZoom": 1, - "maxZoom": 16 - } - }, - "Terrain": { - "options": { - "variant": "terrain", - "minZoom": 0, - "maxZoom": 18 - } - }, - "TerrainBackground": { - "options": { - "variant": "terrain-background", - "minZoom": 0, - "maxZoom": 18 - } - }, - "TopOSMRelief": { - "options": { - "variant": "toposm-color-relief", - "ext": "jpg", - "bounds": [[22, -132], [51, -56]] - } - }, - "TopOSMFeatures": { - "options": { - "variant": "toposm-features", - "bounds": [[22, -132], [51, -56]], - "opacity": 0.9 - } - } - } - }, - "Esri": { - "url": "//server.arcgisonline.com/ArcGIS/rest/services/{variant}/MapServer/tile/{z}/{y}/{x}", - "options": { - "variant": "World_Street_Map", - "attribution": "Tiles © Esri" - }, - "variants": { - "WorldStreetMap": { - "options": { - "attribution": - "Tiles © Esri Source: Esri, DeLorme, NAVTEQ, USGS, Intermap, iPC, NRCAN, Esri Japan, METI, Esri China (Hong Kong), Esri (Thailand), TomTom, 2012" - } - }, - "DeLorme": { - "options": { - "variant": "Specialty/DeLorme_World_Base_Map", - "minZoom": 1, - "maxZoom": 11, - "attribution": "Tiles © Esri — Copyright: ©2012 DeLorme" - } - }, - "WorldTopoMap": { - "options": { - "variant": "World_Topo_Map", - "attribution": "Tiles © Esri Esri, DeLorme, NAVTEQ, TomTom, Intermap, iPC, USGS, FAO, NPS, NRCAN, GeoBase, Kadaster NL, Ordnance Survey, Esri Japan, METI, Esri China (Hong Kong), and the GIS User Community" - } - }, - "WorldImagery": { - "options": { - "variant": "World_Imagery", - "attribution": "Tiles © Esri Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community" - } - }, - "WorldTerrain": { - "options": { - "variant": "World_Terrain_Base", - "maxZoom": 13, - "attribution": "Tiles © Esri Source: USGS, Esri, TANA, DeLorme, and NPS" - } - }, - "WorldShadedRelief": { - "options": { - "variant": "World_Shaded_Relief", - "maxZoom": 13, - "attribution": "{attribution.Esri} — Source: Esri" - } - }, - "WorldPhysical": { - "options": { - "variant": "World_Physical_Map", - "maxZoom": 8, - "attribution": "{attribution.Esri} — Source: US National Park Service" - } - }, - "OceanBasemap": { - "options": { - "variant": "Ocean_Basemap", - "maxZoom": 13, - "attribution": "{attribution.Esri} — Sources: GEBCO, NOAA, CHS, OSU, UNH, CSUMB, National Geographic, DeLorme, NAVTEQ, and Esri" - } - }, - "NatGeoWorldMap": { - "options": { - "variant": "NatGeo_World_Map", - "maxZoom": 16, - "attribution": "{attribution.Esri} — National Geographic, Esri, DeLorme, NAVTEQ, UNEP-WCMC, USGS, NASA, ESA, METI, NRCAN, GEBCO, NOAA, iPC" - } - }, - "WorldGrayCanvas": { - "options": { - "variant": "Canvas/World_Light_Gray_Base", - "maxZoom": 16, - "attribution": "{attribution.Esri} — Esri, DeLorme, NAVTEQ" - } - } - } - }, - "OpenWeatherMap": { - "url": "http://{s}.tile.openweathermap.org/map/{variant}/{z}/{x}/{y}.png", - "options": { - "maxZoom": 19, - "attribution": "Map data © OpenWeatherMap", - "opacity": 0.5 - }, - "variants": { - "Clouds": "clouds", - "CloudsClassic": "clouds_cls", - "Precipitation": "precipitation", - "PrecipitationClassic": "precipitation_cls", - "Rain": "rain", - "RainClassic": "rain_cls", - "Pressure": "pressure", - "PressureContour": "pressure_cntr", - "Wind": "wind", - "Temperature": "temp", - "Snow": "snow" - } - }, - "HERE": { - "url": "//{s}.{base}.maps.cit.api.here.com/maptile/2.1/{type}/{mapID}/{variant}/{z}/{x}/{y}/{size}/{format}?app_id={app_id}&app_code={app_code}&lg={language}", - "options": { - "attribution": - "Map © 1987-2014 HERE", - "subdomains": "1234", - "mapID": "newest", - "app_id": "", - "app_code": "", - "base": "base", - "variant": "normal.day", - "maxZoom": 20, - "type": "maptile", - "language": "eng", - "format": "png8", - "size": "256" - }, - "variants": { - "normalDay": "normal.day", - "normalDayCustom": "normal.day.custom", - "normalDayGrey": "normal.day.grey", - "normalDayMobile": "normal.day.mobile", - "normalDayGreyMobile": "normal.day.grey.mobile", - "normalDayTransit": "normal.day.transit", - "normalDayTransitMobile": "normal.day.transit.mobile", - "normalNight": "normal.night", - "normalNightMobile": "normal.night.mobile", - "normalNightGrey": "normal.night.grey", - "normalNightGreyMobile": "normal.night.grey.mobile", + "OpenStreetMap": { + "url": "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", + "options": { + "maxZoom": 19, + "attribution": "© OpenStreetMap" + }, + "variants": { + "Mapnik": {}, + "BlackAndWhite": { + "url": "http://{s}.tiles.wmflabs.org/bw-mapnik/{z}/{x}/{y}.png", + "options": { + "maxZoom": 18 + } + }, + "DE": { + "url": "https://{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png", + "options": { + "maxZoom": 18 + } + }, + "France": { + "url": "https://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png", + "options": { + "maxZoom": 20, + "attribution": "© Openstreetmap France | {attribution.OpenStreetMap}" + } + }, + "HOT": { + "url": "https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png", + "options": { + "attribution": "{attribution.OpenStreetMap}, Tiles courtesy of Humanitarian OpenStreetMap Team" + } + }, + "BZH": { + "url": "http://tile.openstreetmap.bzh/br/{z}/{x}/{y}.png", + "options": { + "attribution": "{attribution.OpenStreetMap}, Tiles courtesy of Breton OpenStreetMap Team", + "bounds": [[46.2, -5.5], [50, 0.7]] + } + } + } + }, + "OpenSeaMap": { + "url": "https://tiles.openseamap.org/seamark/{z}/{x}/{y}.png", + "options": { + "attribution": "Map data: © OpenSeaMap contributors" + } + }, + "OpenTopoMap": { + "url": "https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png", + "options": { + "maxZoom": 17, + "attribution": "Map data: {attribution.OpenStreetMap}, SRTM | Map style: © OpenTopoMap (CC-BY-SA)" + } + }, + "Thunderforest": { + "url": "https://{s}.tile.thunderforest.com/{variant}/{z}/{x}/{y}.png?apikey={apikey}", + "options": { + "attribution": + "© Thunderforest, {attribution.OpenStreetMap}", + "variant": "cycle", + "apikey": "", + "maxZoom": 22 + }, + "variants": { + "OpenCycleMap": "cycle", + "Transport": { + "options": { + "variant": "transport" + } + }, + "TransportDark": { + "options": { + "variant": "transport-dark" + } + }, + "SpinalMap": { + "options": { + "variant": "spinal-map" + } + }, + "Landscape": "landscape", + "Outdoors": "outdoors", + "Pioneer": "pioneer" + } + }, + "OpenMapSurfer": { + "url": "https://korona.geog.uni-heidelberg.de/tiles/{variant}/x={x}&y={y}&z={z}", + "options": { + "maxZoom": 20, + "variant": "roads", + "attribution": "Imagery from GIScience Research Group @ University of Heidelberg — Map data {attribution.OpenStreetMap}" + }, + "variants": { + "Roads": "roads", + "AdminBounds": { + "options": { + "variant": "adminb", + "maxZoom": 19 + } + }, + "Grayscale": { + "options": { + "variant": "roadsg", + "maxZoom": 19 + } + } + } + }, + "Hydda": { + "url": "https://{s}.tile.openstreetmap.se/hydda/{variant}/{z}/{x}/{y}.png", + "options": { + "maxZoom": 18, + "variant": "full", + "attribution": "Tiles courtesy of OpenStreetMap Sweden — Map data {attribution.OpenStreetMap}" + }, + "variants": { + "Full": "full", + "Base": "base", + "RoadsAndLabels": "roads_and_labels" + } + }, + "MapBox": { + "url": "https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}", + "options": { + "attribution": "Imagery from MapBox — Map data {attribution.OpenStreetMap}", + "subdomains": "abcd", + "id": "streets", + "accessToken": "" + } + }, + "Stamen": { + "url": "https://stamen-tiles-{s}.a.ssl.fastly.net/{variant}/{z}/{x}/{y}.{ext}", + "options": { + "attribution": "Map tiles by Stamen Design, CC BY 3.0 — Map data {attribution.OpenStreetMap}", + "subdomains": "abcd", + "minZoom": 0, + "maxZoom": 20, + "variant": "toner", + "ext": "png" + }, + "variants": { + "Toner": "toner", + "TonerBackground": "toner-background", + "TonerHybrid": "toner-hybrid", + "TonerLines": "toner-lines", + "TonerLabels": "toner-labels", + "TonerLite": "toner-lite", + "Watercolor": { + "options": { + "variant": "watercolor", + "minZoom": 1, + "maxZoom": 16 + } + }, + "Terrain": { + "options": { + "variant": "terrain", + "minZoom": 0, + "maxZoom": 18 + } + }, + "TerrainBackground": { + "options": { + "variant": "terrain-background", + "minZoom": 0, + "maxZoom": 18 + } + }, + "TopOSMRelief": { + "options": { + "variant": "toposm-color-relief", + "ext": "jpg", + "bounds": [[22, -132], [51, -56]] + } + }, + "TopOSMFeatures": { + "options": { + "variant": "toposm-features", + "bounds": [[22, -132], [51, -56]], + "opacity": 0.9 + } + } + } + }, + "Esri": { + "url": "https://server.arcgisonline.com/ArcGIS/rest/services/{variant}/MapServer/tile/{z}/{y}/{x}", + "options": { + "variant": "World_Street_Map", + "attribution": "Tiles © Esri" + }, + "variants": { + "WorldStreetMap": { + "options": { + "attribution": "Tiles © Esri — Source: Esri, DeLorme, NAVTEQ, USGS, Intermap, iPC, NRCAN, Esri Japan, METI, Esri China (Hong Kong), Esri (Thailand), TomTom, 2012" + } + }, + "DeLorme": { + "options": { + "variant": "Specialty/DeLorme_World_Base_Map", + "minZoom": 1, + "maxZoom": 11, + "attribution": "Tiles © Esri — Copyright: ©2012 DeLorme" + } + }, + "WorldTopoMap": { + "options": { + "variant": "World_Topo_Map", + "attribution": "Tiles © Esri — Esri, DeLorme, NAVTEQ, TomTom, Intermap, iPC, USGS, FAO, NPS, NRCAN, GeoBase, Kadaster NL, Ordnance Survey, Esri Japan, METI, Esri China (Hong Kong), and the GIS User Community" + } + }, + "WorldImagery": { + "options": { + "variant": "World_Imagery", + "attribution": "Tiles © Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community" + } + }, + "WorldTerrain": { + "options": { + "variant": "World_Terrain_Base", + "maxZoom": 13, + "attribution": "Tiles © Esri — Source: USGS, Esri, TANA, DeLorme, and NPS" + } + }, + "WorldShadedRelief": { + "options": { + "variant": "World_Shaded_Relief", + "maxZoom": 13, + "attribution": "Tiles © Esri — Source: Esri" + } + }, + "WorldPhysical": { + "options": { + "variant": "World_Physical_Map", + "maxZoom": 8, + "attribution": "Tiles © Esri — Source: US National Park Service" + } + }, + "OceanBasemap": { + "options": { + "variant": "Ocean_Basemap", + "maxZoom": 13, + "attribution": "Tiles © Esri — Sources: GEBCO, NOAA, CHS, OSU, UNH, CSUMB, National Geographic, DeLorme, NAVTEQ, and Esri" + } + }, + "NatGeoWorldMap": { + "options": { + "variant": "NatGeo_World_Map", + "maxZoom": 16, + "attribution": "Tiles © Esri — National Geographic, Esri, DeLorme, NAVTEQ, UNEP-WCMC, USGS, NASA, ESA, METI, NRCAN, GEBCO, NOAA, iPC" + } + }, + "WorldGrayCanvas": { + "options": { + "variant": "Canvas/World_Light_Gray_Base", + "maxZoom": 16, + "attribution": "Tiles © Esri — Esri, DeLorme, NAVTEQ" + } + } + } + }, + "OpenWeatherMap": { + "url": "http://{s}.tile.openweathermap.org/map/{variant}/{z}/{x}/{y}.png?appid={apiKey}", + "options": { + "maxZoom": 19, + "attribution": "Map data © OpenWeatherMap", + "apiKey":"", + "opacity": 0.5 + }, + "variants": { + "Clouds": "clouds", + "CloudsClassic": "clouds_cls", + "Precipitation": "precipitation", + "PrecipitationClassic": "precipitation_cls", + "Rain": "rain", + "RainClassic": "rain_cls", + "Pressure": "pressure", + "PressureContour": "pressure_cntr", + "Wind": "wind", + "Temperature": "temp", + "Snow": "snow" + } + }, + "HERE": { + "url": "https://{s}.{base}.maps.cit.api.here.com/maptile/2.1/{type}/{mapID}/{variant}/{z}/{x}/{y}/{size}/{format}?app_id={app_id}&app_code={app_code}&lg={language}", + "options": { + "attribution": + "Map © 1987-2014 HERE", + "subdomains": "1234", + "mapID": "newest", + "app_id": "", + "app_code": "", + "base": "base", + "variant": "normal.day", + "maxZoom": 20, + "type": "maptile", + "language": "eng", + "format": "png8", + "size": "256" + }, + "variants": { + "normalDay": "normal.day", + "normalDayCustom": "normal.day.custom", + "normalDayGrey": "normal.day.grey", + "normalDayMobile": "normal.day.mobile", + "normalDayGreyMobile": "normal.day.grey.mobile", + "normalDayTransit": "normal.day.transit", + "normalDayTransitMobile": "normal.day.transit.mobile", + "normalNight": "normal.night", + "normalNightMobile": "normal.night.mobile", + "normalNightGrey": "normal.night.grey", + "normalNightGreyMobile": "normal.night.grey.mobile", - "basicMap": { - "options": { - "type": "basetile" - } - }, - "mapLabels": { - "options": { - "type": "labeltile", - "format": "png" - } - }, - "trafficFlow": { - "options": { - "base": "traffic", - "type": "flowtile" - } - }, - "carnavDayGrey": "carnav.day.grey", - "hybridDay": { - "options": { - "base": "aerial", - "variant": "hybrid.day" - } - }, - "hybridDayMobile": { - "options": { - "base": "aerial", - "variant": "hybrid.day.mobile" - } - }, - "pedestrianDay": "pedestrian.day", - "pedestrianNight": "pedestrian.night", - "satelliteDay": { - "options": { - "base": "aerial", - "variant": "satellite.day" - } - }, - "terrainDay": { - "options": { - "base": "aerial", - "variant": "terrain.day" - } - }, - "terrainDayMobile": { - "options": { - "base": "aerial", - "variant": "terrain.day.mobile" - } - } - } - }, - "FreeMapSK": { - "url": "http://t{s}.freemap.sk/T/{z}/{x}/{y}.jpeg", - "options": { - "minZoom": 8, - "maxZoom": 16, - "subdomains": "1234", - "bounds": [[47.204642, 15.996093], [49.830896, 22.576904]], - "attribution": - "{attribution.OpenStreetMap}, vizualization CC-By-SA 2.0 Freemap.sk" - } - }, - "MtbMap": { - "url": "http://tile.mtbmap.cz/mtbmap_tiles/{z}/{x}/{y}.png", - "options": { - "attribution": - "{attribution.OpenStreetMap} & USGS" - } - }, - "CartoDB": { - "url": "http://{s}.basemaps.cartocdn.com/{variant}/{z}/{x}/{y}.png", - "options": { - "attribution": "{attribution.OpenStreetMap} © CartoDB", - "subdomains": "abcd", - "maxZoom": 19, - "variant": "light_all" - }, - "variants": { - "Positron": "light_all", - "PositronNoLabels": "light_nolabels", - "PositronOnlyLabels": "light_only_labels", - "DarkMatter": "dark_all", - "DarkMatterNoLabels": "dark_nolabels", - "DarkMatterOnlyLabels": "dark_only_labels" - } - }, - "HikeBike": { - "url": "http://{s}.tiles.wmflabs.org/{variant}/{z}/{x}/{y}.png", - "options": { - "maxZoom": 19, - "attribution": "{attribution.OpenStreetMap}", - "variant": "hikebike" - }, - "variants": { - "HikeBike": {}, - "HillShading": { - "options": { - "maxZoom": 15, - "variant": "hillshading" - } - } - } - }, - "BasemapAT": { - "url": "//maps{s}.wien.gv.at/basemap/{variant}/normal/google3857/{z}/{y}/{x}.{format}", - "options": { - "maxZoom": 19, - "attribution": "Datenquelle: basemap.at", - "subdomains": ["", "1", "2", "3", "4"], - "format": "png", - "bounds": [[46.358770, 8.782379], [49.037872, 17.189532]], - "variant": "geolandbasemap" - }, - "variants": { - "basemap": "geolandbasemap", - "grau": "bmapgrau", - "overlay": "bmapoverlay", - "highdpi": { - "options": { - "variant": "bmaphidpi", - "format": "jpeg" - } - }, - "orthofoto": { - "options": { - "variant": "bmaporthofoto30cm", - "format": "jpeg" - } - } - } - }, - "NASAGIBS": { - "url": "//map1.vis.earthdata.nasa.gov/wmts-webmerc/{variant}/default/{time}/{tilematrixset}{maxZoom}/{z}/{y}/{x}.{format}", - "options": { - "attribution": - "Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (ESDIS) with funding provided by NASA/HQ.", - "bounds": [[-85.0511287776, -179.999999975], [85.0511287776, 179.999999975]], - "minZoom": 1, - "maxZoom": 9, - "format": "jpg", - "time": "", - "tilematrixset": "GoogleMapsCompatible_Level" - }, - "variants": { - "ModisTerraTrueColorCR": "MODIS_Terra_CorrectedReflectance_TrueColor", - "ModisTerraBands367CR": "MODIS_Terra_CorrectedReflectance_Bands367", - "ViirsEarthAtNight2012": { - "options": { - "variant": "VIIRS_CityLights_2012", - "maxZoom": 8 - } - }, - "ModisTerraLSTDay": { - "options": { - "variant": "MODIS_Terra_Land_Surface_Temp_Day", - "format": "png", - "maxZoom": 7, - "opacity": 0.75 - } - }, - "ModisTerraSnowCover": { - "options": { - "variant": "MODIS_Terra_Snow_Cover", - "format": "png", - "maxZoom": 8, - "opacity": 0.75 - } - }, - "ModisTerraAOD": { - "options": { - "variant": "MODIS_Terra_Aerosol", - "format": "png", - "maxZoom": 6, - "opacity": 0.75 - } - }, - "ModisTerraChlorophyll": { - "options": { - "variant": "MODIS_Terra_Chlorophyll_A", - "format": "png", - "maxZoom": 7, - "opacity": 0.75 - } - } - } - }, - "NLS": { - "url": "//nls-{s}.tileserver.com/nls/{z}/{x}/{y}.jpg", - "options": { - "attribution": "National Library of Scotland Historic Maps", - "bounds": [[49.6, -12], [61.7, 3]], - "minZoom": 1, - "maxZoom": 18, - "subdomains": "0123" - } - } + "basicMap": { + "options": { + "type": "basetile" + } + }, + "mapLabels": { + "options": { + "type": "labeltile", + "format": "png" + } + }, + "trafficFlow": { + "options": { + "base": "traffic", + "type": "flowtile" + } + }, + "carnavDayGrey": "carnav.day.grey", + "hybridDay": { + "options": { + "base": "aerial", + "variant": "hybrid.day" + } + }, + "hybridDayMobile": { + "options": { + "base": "aerial", + "variant": "hybrid.day.mobile" + } + }, + "pedestrianDay": "pedestrian.day", + "pedestrianNight": "pedestrian.night", + "satelliteDay": { + "options": { + "base": "aerial", + "variant": "satellite.day" + } + }, + "terrainDay": { + "options": { + "base": "aerial", + "variant": "terrain.day" + } + }, + "terrainDayMobile": { + "options": { + "base": "aerial", + "variant": "terrain.day.mobile" + } + } + } + }, + "FreeMapSK": { + "url": "http://t{s}.freemap.sk/T/{z}/{x}/{y}.jpeg", + "options": { + "minZoom": 8, + "maxZoom": 16, + "subdomains": "1234", + "bounds": [[47.204642, 15.996093], [49.830896, 22.576904]], + "attribution": + "{attribution.OpenStreetMap}, vizualization CC-By-SA 2.0 Freemap.sk" + } + }, + "MtbMap": { + "url": "http://tile.mtbmap.cz/mtbmap_tiles/{z}/{x}/{y}.png", + "options": { + "attribution": + "{attribution.OpenStreetMap} & USGS" + } + }, + "CartoDB": { + "url": "https://cartodb-basemaps-{s}.global.ssl.fastly.net/{variant}/{z}/{x}/{y}.png", + "options": { + "attribution": "{attribution.OpenStreetMap} © CartoDB", + "subdomains": "abcd", + "maxZoom": 19, + "variant": "light_all" + }, + "variants": { + "Positron": "light_all", + "PositronNoLabels": "light_nolabels", + "PositronOnlyLabels": "light_only_labels", + "DarkMatter": "dark_all", + "DarkMatterNoLabels": "dark_nolabels", + "DarkMatterOnlyLabels": "dark_only_labels" + } + }, + "HikeBike": { + "url": "http://{s}.tiles.wmflabs.org/{variant}/{z}/{x}/{y}.png", + "options": { + "maxZoom": 19, + "attribution": "{attribution.OpenStreetMap}", + "variant": "hikebike" + }, + "variants": { + "HikeBike": {}, + "HillShading": { + "options": { + "maxZoom": 15, + "variant": "hillshading" + } + } + } + }, + "BasemapAT": { + "url": "https://maps{s}.wien.gv.at/basemap/{variant}/normal/google3857/{z}/{y}/{x}.{format}", + "options": { + "maxZoom": 19, + "attribution": "Datenquelle: basemap.at", + "subdomains": ["", "1", "2", "3", "4"], + "format": "png", + "bounds": [[46.358770, 8.782379], [49.037872, 17.189532]], + "variant": "geolandbasemap" + }, + "variants": { + "basemap": { + "options": { + "maxZoom": 20, + "variant": "geolandbasemap" + } + }, + "grau": "bmapgrau", + "overlay": "bmapoverlay", + "highdpi": { + "options": { + "variant": "bmaphidpi", + "format": "jpeg" + } + }, + "orthofoto": { + "options": { + "maxZoom": 20, + "variant": "bmaporthofoto30cm", + "format": "jpeg" + } + } + } + }, + "nlmaps": { + "url": "https://geodata.nationaalgeoregister.nl/tiles/service/wmts/{variant}/EPSG:3857/{z}/{x}/{y}.png", + "options": { + "minZoom": 6, + "maxZoom": 19, + "bounds": [[50.5, 3.25], [54, 7.6]], + "attribution": "Kaartgegevens © Kadaster" + }, + "variants": { + "standaard": "brtachtergrondkaart", + "pastel": "brtachtergrondkaartpastel", + "grijs": "brtachtergrondkaartgrijs", + "luchtfoto": { + "url": "https://geodata.nationaalgeoregister.nl/luchtfoto/rgb/wmts/1.0.0/2016_ortho25/EPSG:3857/{z}/{x}/{y}.png" + } + } + }, + "NASAGIBS": { + "url": "https://map1.vis.earthdata.nasa.gov/wmts-webmerc/{variant}/default/{time}/{tilematrixset}{maxZoom}/{z}/{y}/{x}.{format}", + "options": { + "attribution": "Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (ESDIS) with funding provided by NASA/HQ.", + "bounds": [[-85.0511287776, -179.999999975], [85.0511287776, 179.999999975]], + "minZoom": 1, + "maxZoom": 9, + "format": "jpg", + "time": "", + "tilematrixset": "GoogleMapsCompatible_Level" + }, + "variants": { + "ModisTerraTrueColorCR": "MODIS_Terra_CorrectedReflectance_TrueColor", + "ModisTerraBands367CR": "MODIS_Terra_CorrectedReflectance_Bands367", + "ViirsEarthAtNight2012": { + "options": { + "variant": "VIIRS_CityLights_2012", + "maxZoom": 8 + } + }, + "ModisTerraLSTDay": { + "options": { + "variant": "MODIS_Terra_Land_Surface_Temp_Day", + "format": "png", + "maxZoom": 7, + "opacity": 0.75 + } + }, + "ModisTerraSnowCover": { + "options": { + "variant": "MODIS_Terra_Snow_Cover", + "format": "png", + "maxZoom": 8, + "opacity": 0.75 + } + }, + "ModisTerraAOD": { + "options": { + "variant": "MODIS_Terra_Aerosol", + "format": "png", + "maxZoom": 6, + "opacity": 0.75 + } + }, + "ModisTerraChlorophyll": { + "options": { + "variant": "MODIS_Terra_Chlorophyll_A", + "format": "png", + "maxZoom": 7, + "opacity": 0.75 + } + } + } + }, + "NLS": { + "url": "https://nls-{s}.tileserver.com/nls/{z}/{x}/{y}.jpg", + "options": { + "attribution": "National Library of Scotland Historic Maps", + "bounds": [[49.6, -12], [61.7, 3]], + "minZoom": 1, + "maxZoom": 18, + "subdomains": "0123" + } + }, + "JusticeMap": { + "url": "http://www.justicemap.org/tile/{size}/{variant}/{z}/{x}/{y}.png", + "options": { + "attribution": "Justice Map", + "size": "county", + "bounds": [[14, -180], [72, -56]] + }, + "variants": { + "income": "income", + "americanIndian": "indian", + "asian": "asian", + "black": "black", + "hispanic": "hispanic", + "multi": "multi", + "nonWhite": "nonwhite", + "white": "white", + "plurality": "plural" + } + } } diff --git a/inst/htmlwidgets/lib/leaflet/images/1px.png b/inst/htmlwidgets/lib/leaflet/images/1px.png new file mode 100644 index 000000000..9da19eaca Binary files /dev/null and b/inst/htmlwidgets/lib/leaflet/images/1px.png differ diff --git a/inst/htmlwidgets/plugins/Leaflet-MiniMap/Control.MiniMap.js b/inst/htmlwidgets/plugins/Leaflet-MiniMap/Control.MiniMap.js index c2b053502..e0205475d 100644 --- a/inst/htmlwidgets/plugins/Leaflet-MiniMap/Control.MiniMap.js +++ b/inst/htmlwidgets/plugins/Leaflet-MiniMap/Control.MiniMap.js @@ -20,6 +20,9 @@ }(function (L) { var MiniMap = L.Control.extend({ + + includes: L.Mixin.Events, + options: { position: 'bottomright', toggleDisplay: false, @@ -127,13 +130,21 @@ _addToggleButton: function () { this._toggleDisplayButton = this.options.toggleDisplay ? this._createButton( - '', this.options.strings.hideText, ('leaflet-control-minimap-toggle-display leaflet-control-minimap-toggle-display-' + + '', this._toggleButtonInitialTitleText(), ('leaflet-control-minimap-toggle-display leaflet-control-minimap-toggle-display-' + this.options.position), this._container, this._toggleDisplayButtonClicked, this) : undefined; this._toggleDisplayButton.style.width = this.options.collapsedWidth + 'px'; this._toggleDisplayButton.style.height = this.options.collapsedHeight + 'px'; }, + _toggleButtonInitialTitleText: function () { + if (this.options.minimized) { + return this.options.strings.showText; + } else { + return this.options.strings.hideText; + } + }, + _createButton: function (html, title, className, container, fn, context) { var link = L.DomUtil.create('a', className, container); link.innerHTML = html; @@ -182,6 +193,7 @@ this._container.style.display = 'none'; } this._minimized = true; + this._onToggle(); }, _restore: function () { @@ -195,6 +207,7 @@ this._container.style.display = 'block'; } this._minimized = false; + this._onToggle(); }, _onMainMapMoved: function (e) { @@ -305,6 +318,22 @@ _isDefined: function (value) { return typeof value !== 'undefined'; + }, + + _onToggle: function () { + L.Util.requestAnimFrame(function () { + L.DomEvent.on(this._container, 'transitionend', this._fireToggleEvents, this); + if (!L.Browser.any3d) { + L.Util.requestAnimFrame(this._fireToggleEvents, this); + } + }, this); + }, + + _fireToggleEvents: function () { + L.DomEvent.off(this._container, 'transitionend', this._fireToggleEvents, this); + var data = { minimized: this._minimized }; + this.fire(this._minimized ? 'minimize' : 'restore', data); + this.fire('toggle', data); } }); diff --git a/inst/htmlwidgets/plugins/Leaflet-MiniMap/Control.MiniMap.min.js b/inst/htmlwidgets/plugins/Leaflet-MiniMap/Control.MiniMap.min.js index 41a68632e..fa6cbd502 100644 --- a/inst/htmlwidgets/plugins/Leaflet-MiniMap/Control.MiniMap.min.js +++ b/inst/htmlwidgets/plugins/Leaflet-MiniMap/Control.MiniMap.min.js @@ -1 +1 @@ -(function(factory,window){if(typeof define==="function"&&define.amd){define(["leaflet"],factory)}else if(typeof exports==="object"){module.exports=factory(require("leaflet"))}if(typeof window!=="undefined"&&window.L){window.L.Control.MiniMap=factory(L);window.L.control.minimap=function(layer,options){return new window.L.Control.MiniMap(layer,options)}}})(function(L){var MiniMap=L.Control.extend({options:{position:"bottomright",toggleDisplay:false,zoomLevelOffset:-5,zoomLevelFixed:false,centerFixed:false,zoomAnimation:false,autoToggleDisplay:false,minimized:false,width:150,height:150,collapsedWidth:19,collapsedHeight:19,aimingRectOptions:{color:"#ff7800",weight:1,clickable:false},shadowRectOptions:{color:"#000000",weight:1,clickable:false,opacity:0,fillOpacity:0},strings:{hideText:"Hide MiniMap",showText:"Show MiniMap"},mapOptions:{}},initialize:function(layer,options){L.Util.setOptions(this,options);this.options.aimingRectOptions.clickable=false;this.options.shadowRectOptions.clickable=false;this._layer=layer},onAdd:function(map){this._mainMap=map;this._container=L.DomUtil.create("div","leaflet-control-minimap");this._container.style.width=this.options.width+"px";this._container.style.height=this.options.height+"px";L.DomEvent.disableClickPropagation(this._container);L.DomEvent.on(this._container,"mousewheel",L.DomEvent.stopPropagation);var mapOptions={attributionControl:false,dragging:!this.options.centerFixed,zoomControl:false,zoomAnimation:this.options.zoomAnimation,autoToggleDisplay:this.options.autoToggleDisplay,touchZoom:this.options.centerFixed?"center":!this._isZoomLevelFixed(),scrollWheelZoom:this.options.centerFixed?"center":!this._isZoomLevelFixed(),doubleClickZoom:this.options.centerFixed?"center":!this._isZoomLevelFixed(),boxZoom:!this._isZoomLevelFixed(),crs:map.options.crs};mapOptions=L.Util.extend(this.options.mapOptions,mapOptions);this._miniMap=new L.Map(this._container,mapOptions);this._miniMap.addLayer(this._layer);this._mainMapMoving=false;this._miniMapMoving=false;this._userToggledDisplay=false;this._minimized=false;if(this.options.toggleDisplay){this._addToggleButton()}this._miniMap.whenReady(L.Util.bind(function(){this._aimingRect=L.rectangle(this._mainMap.getBounds(),this.options.aimingRectOptions).addTo(this._miniMap);this._shadowRect=L.rectangle(this._mainMap.getBounds(),this.options.shadowRectOptions).addTo(this._miniMap);this._mainMap.on("moveend",this._onMainMapMoved,this);this._mainMap.on("move",this._onMainMapMoving,this);this._miniMap.on("movestart",this._onMiniMapMoveStarted,this);this._miniMap.on("move",this._onMiniMapMoving,this);this._miniMap.on("moveend",this._onMiniMapMoved,this)},this));return this._container},addTo:function(map){L.Control.prototype.addTo.call(this,map);var center=this.options.centerFixed||this._mainMap.getCenter();this._miniMap.setView(center,this._decideZoom(true));this._setDisplay(this.options.minimized);return this},onRemove:function(map){this._mainMap.off("moveend",this._onMainMapMoved,this);this._mainMap.off("move",this._onMainMapMoving,this);this._miniMap.off("moveend",this._onMiniMapMoved,this);this._miniMap.removeLayer(this._layer)},changeLayer:function(layer){this._miniMap.removeLayer(this._layer);this._layer=layer;this._miniMap.addLayer(this._layer)},_addToggleButton:function(){this._toggleDisplayButton=this.options.toggleDisplay?this._createButton("",this.options.strings.hideText,"leaflet-control-minimap-toggle-display leaflet-control-minimap-toggle-display-"+this.options.position,this._container,this._toggleDisplayButtonClicked,this):undefined;this._toggleDisplayButton.style.width=this.options.collapsedWidth+"px";this._toggleDisplayButton.style.height=this.options.collapsedHeight+"px"},_createButton:function(html,title,className,container,fn,context){var link=L.DomUtil.create("a",className,container);link.innerHTML=html;link.href="#";link.title=title;var stop=L.DomEvent.stopPropagation;L.DomEvent.on(link,"click",stop).on(link,"mousedown",stop).on(link,"dblclick",stop).on(link,"click",L.DomEvent.preventDefault).on(link,"click",fn,context);return link},_toggleDisplayButtonClicked:function(){this._userToggledDisplay=true;if(!this._minimized){this._minimize();this._toggleDisplayButton.title=this.options.strings.showText}else{this._restore();this._toggleDisplayButton.title=this.options.strings.hideText}},_setDisplay:function(minimize){if(minimize!==this._minimized){if(!this._minimized){this._minimize()}else{this._restore()}}},_minimize:function(){if(this.options.toggleDisplay){this._container.style.width=this.options.collapsedWidth+"px";this._container.style.height=this.options.collapsedHeight+"px";this._toggleDisplayButton.className+=" minimized-"+this.options.position}else{this._container.style.display="none"}this._minimized=true},_restore:function(){if(this.options.toggleDisplay){this._container.style.width=this.options.width+"px";this._container.style.height=this.options.height+"px";this._toggleDisplayButton.className=this._toggleDisplayButton.className.replace("minimized-"+this.options.position,"")}else{this._container.style.display="block"}this._minimized=false},_onMainMapMoved:function(e){if(!this._miniMapMoving){var center=this.options.centerFixed||this._mainMap.getCenter();this._mainMapMoving=true;this._miniMap.setView(center,this._decideZoom(true));this._setDisplay(this._decideMinimized())}else{this._miniMapMoving=false}this._aimingRect.setBounds(this._mainMap.getBounds())},_onMainMapMoving:function(e){this._aimingRect.setBounds(this._mainMap.getBounds())},_onMiniMapMoveStarted:function(e){if(!this.options.centerFixed){var lastAimingRect=this._aimingRect.getBounds();var sw=this._miniMap.latLngToContainerPoint(lastAimingRect.getSouthWest());var ne=this._miniMap.latLngToContainerPoint(lastAimingRect.getNorthEast());this._lastAimingRectPosition={sw:sw,ne:ne}}},_onMiniMapMoving:function(e){if(!this.options.centerFixed){if(!this._mainMapMoving&&this._lastAimingRectPosition){this._shadowRect.setBounds(new L.LatLngBounds(this._miniMap.containerPointToLatLng(this._lastAimingRectPosition.sw),this._miniMap.containerPointToLatLng(this._lastAimingRectPosition.ne)));this._shadowRect.setStyle({opacity:1,fillOpacity:.3})}}},_onMiniMapMoved:function(e){if(!this._mainMapMoving){this._miniMapMoving=true;this._mainMap.setView(this._miniMap.getCenter(),this._decideZoom(false));this._shadowRect.setStyle({opacity:0,fillOpacity:0})}else{this._mainMapMoving=false}},_isZoomLevelFixed:function(){var zoomLevelFixed=this.options.zoomLevelFixed;return this._isDefined(zoomLevelFixed)&&this._isInteger(zoomLevelFixed)},_decideZoom:function(fromMaintoMini){if(!this._isZoomLevelFixed()){if(fromMaintoMini){return this._mainMap.getZoom()+this.options.zoomLevelOffset}else{var currentDiff=this._miniMap.getZoom()-this._mainMap.getZoom();var proposedZoom=this._miniMap.getZoom()-this.options.zoomLevelOffset;var toRet;if(currentDiff>this.options.zoomLevelOffset&&this._mainMap.getZoom()this._lastMiniMapZoom){toRet=this._mainMap.getZoom()+1;this._miniMap.setZoom(this._miniMap.getZoom()-1)}else{toRet=this._mainMap.getZoom()}}else{toRet=proposedZoom}this._lastMiniMapZoom=this._miniMap.getZoom();return toRet}}else{if(fromMaintoMini){return this.options.zoomLevelFixed}else{return this._mainMap.getZoom()}}},_decideMinimized:function(){if(this._userToggledDisplay){return this._minimized}if(this.options.autoToggleDisplay){if(this._mainMap.getBounds().contains(this._miniMap.getBounds())){return true}return false}return this._minimized},_isInteger:function(value){return typeof value==="number"},_isDefined:function(value){return typeof value!=="undefined"}});L.Map.mergeOptions({miniMapControl:false});L.Map.addInitHook(function(){if(this.options.miniMapControl){this.miniMapControl=(new MiniMap).addTo(this)}});return MiniMap},window); \ No newline at end of file +(function(factory,window){if(typeof define==="function"&&define.amd){define(["leaflet"],factory)}else if(typeof exports==="object"){module.exports=factory(require("leaflet"))}if(typeof window!=="undefined"&&window.L){window.L.Control.MiniMap=factory(L);window.L.control.minimap=function(layer,options){return new window.L.Control.MiniMap(layer,options)}}})(function(L){var MiniMap=L.Control.extend({includes:L.Mixin.Events,options:{position:"bottomright",toggleDisplay:false,zoomLevelOffset:-5,zoomLevelFixed:false,centerFixed:false,zoomAnimation:false,autoToggleDisplay:false,minimized:false,width:150,height:150,collapsedWidth:19,collapsedHeight:19,aimingRectOptions:{color:"#ff7800",weight:1,clickable:false},shadowRectOptions:{color:"#000000",weight:1,clickable:false,opacity:0,fillOpacity:0},strings:{hideText:"Hide MiniMap",showText:"Show MiniMap"},mapOptions:{}},initialize:function(layer,options){L.Util.setOptions(this,options);this.options.aimingRectOptions.clickable=false;this.options.shadowRectOptions.clickable=false;this._layer=layer},onAdd:function(map){this._mainMap=map;this._container=L.DomUtil.create("div","leaflet-control-minimap");this._container.style.width=this.options.width+"px";this._container.style.height=this.options.height+"px";L.DomEvent.disableClickPropagation(this._container);L.DomEvent.on(this._container,"mousewheel",L.DomEvent.stopPropagation);var mapOptions={attributionControl:false,dragging:!this.options.centerFixed,zoomControl:false,zoomAnimation:this.options.zoomAnimation,autoToggleDisplay:this.options.autoToggleDisplay,touchZoom:this.options.centerFixed?"center":!this._isZoomLevelFixed(),scrollWheelZoom:this.options.centerFixed?"center":!this._isZoomLevelFixed(),doubleClickZoom:this.options.centerFixed?"center":!this._isZoomLevelFixed(),boxZoom:!this._isZoomLevelFixed(),crs:map.options.crs};mapOptions=L.Util.extend(this.options.mapOptions,mapOptions);this._miniMap=new L.Map(this._container,mapOptions);this._miniMap.addLayer(this._layer);this._mainMapMoving=false;this._miniMapMoving=false;this._userToggledDisplay=false;this._minimized=false;if(this.options.toggleDisplay){this._addToggleButton()}this._miniMap.whenReady(L.Util.bind(function(){this._aimingRect=L.rectangle(this._mainMap.getBounds(),this.options.aimingRectOptions).addTo(this._miniMap);this._shadowRect=L.rectangle(this._mainMap.getBounds(),this.options.shadowRectOptions).addTo(this._miniMap);this._mainMap.on("moveend",this._onMainMapMoved,this);this._mainMap.on("move",this._onMainMapMoving,this);this._miniMap.on("movestart",this._onMiniMapMoveStarted,this);this._miniMap.on("move",this._onMiniMapMoving,this);this._miniMap.on("moveend",this._onMiniMapMoved,this)},this));return this._container},addTo:function(map){L.Control.prototype.addTo.call(this,map);var center=this.options.centerFixed||this._mainMap.getCenter();this._miniMap.setView(center,this._decideZoom(true));this._setDisplay(this.options.minimized);return this},onRemove:function(map){this._mainMap.off("moveend",this._onMainMapMoved,this);this._mainMap.off("move",this._onMainMapMoving,this);this._miniMap.off("moveend",this._onMiniMapMoved,this);this._miniMap.removeLayer(this._layer)},changeLayer:function(layer){this._miniMap.removeLayer(this._layer);this._layer=layer;this._miniMap.addLayer(this._layer)},_addToggleButton:function(){this._toggleDisplayButton=this.options.toggleDisplay?this._createButton("",this._toggleButtonInitialTitleText(),"leaflet-control-minimap-toggle-display leaflet-control-minimap-toggle-display-"+this.options.position,this._container,this._toggleDisplayButtonClicked,this):undefined;this._toggleDisplayButton.style.width=this.options.collapsedWidth+"px";this._toggleDisplayButton.style.height=this.options.collapsedHeight+"px"},_toggleButtonInitialTitleText:function(){if(this.options.minimized){return this.options.strings.showText}else{return this.options.strings.hideText}},_createButton:function(html,title,className,container,fn,context){var link=L.DomUtil.create("a",className,container);link.innerHTML=html;link.href="#";link.title=title;var stop=L.DomEvent.stopPropagation;L.DomEvent.on(link,"click",stop).on(link,"mousedown",stop).on(link,"dblclick",stop).on(link,"click",L.DomEvent.preventDefault).on(link,"click",fn,context);return link},_toggleDisplayButtonClicked:function(){this._userToggledDisplay=true;if(!this._minimized){this._minimize()}else{this._restore()}},_setDisplay:function(minimize){if(minimize!==this._minimized){if(!this._minimized){this._minimize()}else{this._restore()}}},_minimize:function(){if(this.options.toggleDisplay){this._container.style.width=this.options.collapsedWidth+"px";this._container.style.height=this.options.collapsedHeight+"px";this._toggleDisplayButton.className+=" minimized-"+this.options.position;this._toggleDisplayButton.title=this.options.strings.showText}else{this._container.style.display="none"}this._minimized=true;this._onToggle()},_restore:function(){if(this.options.toggleDisplay){this._container.style.width=this.options.width+"px";this._container.style.height=this.options.height+"px";this._toggleDisplayButton.className=this._toggleDisplayButton.className.replace("minimized-"+this.options.position,"");this._toggleDisplayButton.title=this.options.strings.hideText}else{this._container.style.display="block"}this._minimized=false;this._onToggle()},_onMainMapMoved:function(e){if(!this._miniMapMoving){var center=this.options.centerFixed||this._mainMap.getCenter();this._mainMapMoving=true;this._miniMap.setView(center,this._decideZoom(true));this._setDisplay(this._decideMinimized())}else{this._miniMapMoving=false}this._aimingRect.setBounds(this._mainMap.getBounds())},_onMainMapMoving:function(e){this._aimingRect.setBounds(this._mainMap.getBounds())},_onMiniMapMoveStarted:function(e){if(!this.options.centerFixed){var lastAimingRect=this._aimingRect.getBounds();var sw=this._miniMap.latLngToContainerPoint(lastAimingRect.getSouthWest());var ne=this._miniMap.latLngToContainerPoint(lastAimingRect.getNorthEast());this._lastAimingRectPosition={sw:sw,ne:ne}}},_onMiniMapMoving:function(e){if(!this.options.centerFixed){if(!this._mainMapMoving&&this._lastAimingRectPosition){this._shadowRect.setBounds(new L.LatLngBounds(this._miniMap.containerPointToLatLng(this._lastAimingRectPosition.sw),this._miniMap.containerPointToLatLng(this._lastAimingRectPosition.ne)));this._shadowRect.setStyle({opacity:1,fillOpacity:.3})}}},_onMiniMapMoved:function(e){if(!this._mainMapMoving){this._miniMapMoving=true;this._mainMap.setView(this._miniMap.getCenter(),this._decideZoom(false));this._shadowRect.setStyle({opacity:0,fillOpacity:0})}else{this._mainMapMoving=false}},_isZoomLevelFixed:function(){var zoomLevelFixed=this.options.zoomLevelFixed;return this._isDefined(zoomLevelFixed)&&this._isInteger(zoomLevelFixed)},_decideZoom:function(fromMaintoMini){if(!this._isZoomLevelFixed()){if(fromMaintoMini){return this._mainMap.getZoom()+this.options.zoomLevelOffset}else{var currentDiff=this._miniMap.getZoom()-this._mainMap.getZoom();var proposedZoom=this._miniMap.getZoom()-this.options.zoomLevelOffset;var toRet;if(currentDiff>this.options.zoomLevelOffset&&this._mainMap.getZoom()this._lastMiniMapZoom){toRet=this._mainMap.getZoom()+1;this._miniMap.setZoom(this._miniMap.getZoom()-1)}else{toRet=this._mainMap.getZoom()}}else{toRet=proposedZoom}this._lastMiniMapZoom=this._miniMap.getZoom();return toRet}}else{if(fromMaintoMini){return this.options.zoomLevelFixed}else{return this._mainMap.getZoom()}}},_decideMinimized:function(){if(this._userToggledDisplay){return this._minimized}if(this.options.autoToggleDisplay){if(this._mainMap.getBounds().contains(this._miniMap.getBounds())){return true}return false}return this._minimized},_isInteger:function(value){return typeof value==="number"},_isDefined:function(value){return typeof value!=="undefined"},_onToggle:function(){L.Util.requestAnimFrame(function(){L.DomEvent.on(this._container,"transitionend",this._fireToggleEvents,this);if(!L.Browser.any3d){L.Util.requestAnimFrame(this._fireToggleEvents,this)}},this)},_fireToggleEvents:function(){L.DomEvent.off(this._container,"transitionend",this._fireToggleEvents,this);var data={minimized:this._minimized};this.fire(this._minimized?"minimize":"restore",data);this.fire("toggle",data)}});L.Map.mergeOptions({miniMapControl:false});L.Map.addInitHook(function(){if(this.options.miniMapControl){this.miniMapControl=(new MiniMap).addTo(this)}});return MiniMap},window); \ No newline at end of file diff --git a/inst/htmlwidgets/plugins/Leaflet.EasyButton/easy-button.js b/inst/htmlwidgets/plugins/Leaflet.EasyButton/easy-button.js index f03f3bd88..579dca691 100644 --- a/inst/htmlwidgets/plugins/Leaflet.EasyButton/easy-button.js +++ b/inst/htmlwidgets/plugins/Leaflet.EasyButton/easy-button.js @@ -169,10 +169,8 @@ L.Control.EasyButton = L.Control.extend({ this.button = L.DomUtil.create(this.options.tagName, ''); - // the next three if statements should be collapsed into the options - // when it's time for breaking changes. - if (this.tagName === 'button') { - this.button.type = 'button'; + if (this.options.tagName === 'button') { + this.button.setAttribute('type', 'button'); } if (this.options.id ){ @@ -191,7 +189,7 @@ L.Control.EasyButton = L.Control.extend({ L.DomEvent.addListener(this.button,'click', function(e){ L.DomEvent.stop(e); this._currentState.onClick(this, this._map ? this._map : null ); - this._map.getContainer().focus(); + this._map && this._map.getContainer().focus(); }, this); // prep the contents of the control @@ -279,8 +277,6 @@ L.Control.EasyButton = L.Control.extend({ } }, - - enable: function(){ L.DomUtil.addClass(this.button, 'enabled'); L.DomUtil.removeClass(this.button, 'disabled'); @@ -288,8 +284,6 @@ L.Control.EasyButton = L.Control.extend({ return this; }, - - disable: function(){ L.DomUtil.addClass(this.button, 'disabled'); L.DomUtil.removeClass(this.button, 'enabled'); @@ -297,24 +291,21 @@ L.Control.EasyButton = L.Control.extend({ return this; }, - - removeFrom: function (map) { - - this._container.parentNode.removeChild(this._container); - this._map = null; - - return this; - }, - - onAdd: function(){ - var containerObj = L.easyBar([this], { + onAdd: function(map){ + var bar = L.easyBar([this], { position: this.options.position, leafletClasses: this.options.leafletClasses }); - this._container = containerObj.container; - return this._container; - } + this._anonymousBar = bar; + this._container = bar.container; + return this._anonymousBar.container; + }, + removeFrom: function (map) { + if (this._map === map) + this.remove(); + return this; + }, }); diff --git a/inst/htmlwidgets/plugins/Leaflet.Graticule/Leaflet.Graticule.js b/inst/htmlwidgets/plugins/Leaflet.Graticule/Leaflet.Graticule.js new file mode 100644 index 000000000..ecce0c123 --- /dev/null +++ b/inst/htmlwidgets/plugins/Leaflet.Graticule/Leaflet.Graticule.js @@ -0,0 +1,518 @@ +/** +* Create a Canvas as ImageOverlay to draw the Lat/Lon Graticule, +* and show the axis tick label on the edge of the map. +* Author: lanwei@cloudybay.com.tw +*/ + +L.LatLngGraticule = L.Layer.extend({ + options: { + showLabel: true, + opacity: 1, + weight: 0.8, + color: '#aaa', + font: '12px Verdana', + lngLineCurved: 0, + latLineCurved: 0, + zoomInterval: [ + {start: 2, end: 2, interval: 40}, + {start: 3, end: 3, interval: 20}, + {start: 4, end: 4, interval: 10}, + {start: 5, end: 7, interval: 5}, + {start: 8, end: 20, interval: 1} + ] + }, + + initialize: function (options) { + L.setOptions(this, options); + + var defaultFontName = 'Verdana'; + var _ff = this.options.font.split(' '); + if (_ff.length < 2) { + this.options.font += ' ' + defaultFontName; + } + + if (!this.options.fontColor) { + this.options.fontColor = this.options.color; + } + + if (this.options.zoomInterval) { + if (this.options.zoomInterval.latitude) { + this.options.latInterval = this.options.zoomInterval.latitude; + if (!this.options.zoomInterval.longitude) { + this.options.lngInterval = this.options.zoomInterval.latitude; + } + } + if (this.options.zoomInterval.longitude) { + this.options.lngInterval = this.options.zoomInterval.longitude; + if (!this.options.zoomInterval.latitude) { + this.options.latInterval = this.options.zoomInterval.longitude; + } + } + if (!this.options.latInterval) { + this.options.latInterval = this.options.zoomInterval; + } + if (!this.options.lngInterval) { + this.options.lngInterval = this.options.zoomInterval; + } + } + }, + + onAdd: function (map) { + this._map = map; + + if (!this._container) { + this._initCanvas(); + } + + map._panes.overlayPane.appendChild(this._container); + + map.on('viewreset', this._reset, this); + map.on('move', this._reset, this); + map.on('moveend', this._reset, this); + +// if (map.options.zoomAnimation && L.Browser.any3d) { +// map.on('zoom', this._animateZoom, this); +// } + + this._reset(); + }, + + onRemove: function (map) { + map.getPanes().overlayPane.removeChild(this._container); + + map.off('viewreset', this._reset, this); + map.off('move', this._reset, this); + map.off('moveend', this._reset, this); + +// if (map.options.zoomAnimation) { +// map.off('zoom', this._animateZoom, this); +// } + }, + + addTo: function (map) { + map.addLayer(this); + return this; + }, + + setOpacity: function (opacity) { + this.options.opacity = opacity; + this._updateOpacity(); + return this; + }, + + bringToFront: function () { + if (this._canvas) { + this._map._panes.overlayPane.appendChild(this._canvas); + } + return this; + }, + + bringToBack: function () { + var pane = this._map._panes.overlayPane; + if (this._canvas) { + pane.insertBefore(this._canvas, pane.firstChild); + } + return this; + }, + + getAttribution: function () { + return this.options.attribution; + }, + + _initCanvas: function () { + this._container = L.DomUtil.create('div', 'leaflet-image-layer'); + + this._canvas = L.DomUtil.create('canvas', ''); + + if (this._map.options.zoomAnimation && L.Browser.any3d) { + L.DomUtil.addClass(this._canvas, 'leaflet-zoom-animated'); + } else { + L.DomUtil.addClass(this._canvas, 'leaflet-zoom-hide'); + } + + this._updateOpacity(); + + this._container.appendChild(this._canvas); + + L.extend(this._canvas, { + onselectstart: L.Util.falseFn, + onmousemove: L.Util.falseFn, + onload: L.bind(this._onCanvasLoad, this) + }); + }, + +// _animateZoom: function (e) { +// var map = this._map, +// container = this._container, +// canvas = this._canvas, +// zoom = map.getZoom(), +// center = map.getCenter(), +// scale = map.getZoomScale(zoom), +// nw = map.containerPointToLatLng([0, 0]), +// se = map.containerPointToLatLng([canvas.width, canvas.height]), +// +// topLeft = map._latLngToNewLayerPoint(nw, zoom, center), +// size = map._latLngToNewLayerPoint(se, zoom, center)._subtract(topLeft), +// origin = topLeft._add(size._multiplyBy((1 / 2) * (1 - 1 / scale))); +// +// L.DomUtil.setTransform(container, origin, scale); +// }, + + _reset: function () { + var container = this._container, + canvas = this._canvas, + size = this._map.getSize(), + lt = this._map.containerPointToLayerPoint([0, 0]); + + L.DomUtil.setPosition(container, lt); + + container.style.width = size.x + 'px'; + container.style.height = size.y + 'px'; + + canvas.width = size.x; + canvas.height = size.y; + canvas.style.width = size.x + 'px'; + canvas.style.height = size.y + 'px'; + + this.__calcInterval(); + + this.__draw(true); + }, + + _onCanvasLoad: function () { + this.fire('load'); + }, + + _updateOpacity: function () { + L.DomUtil.setOpacity(this._canvas, this.options.opacity); + }, + + __format_lat: function(lat) { + if (this.options.latFormatTickLabel) { + return this.options.latFormatTickLabel(lat); + } + + // todo: format type of float + if (lat < 0) { + return '' + (lat*-1) + 'S'; + } + else if (lat > 0) { + return '' + lat + 'N'; + } + return '' + lat; + }, + + __format_lng: function(lng) { + if (this.options.lngFormatTickLabel) { + return this.options.lngFormatTickLabel(lng); + } + + // todo: format type of float + if (lng > 180) { + return '' + (360 - lng) + 'W'; + } + else if (lng > 0 && lng < 180) { + return '' + lng + 'E'; + } + else if (lng < 0 && lng > -180) { + return '' + (lng*-1) + 'W'; + } + else if (lng == -180) { + return '' + (lng*-1); + } + else if (lng < -180) { + return '' + (360 + lng) + 'W'; + } + return '' + lng; + }, + + __calcInterval: function() { + var zoom = this._map.getZoom(); + if (this._currZoom != zoom) { + this._currLngInterval = 0; + this._currLatInterval = 0; + this._currZoom = zoom; + } + + var interv; + + if (!this._currLngInterval) { + try { + for (var idx in this.options.lngInterval) { + var dict = this.options.lngInterval[idx]; + if (dict.start <= zoom) { + if (dict.end && dict.end >= zoom) { + this._currLngInterval = dict.interval; + break; + } + } + } + } + catch(e) { + this._currLngInterval = 0; + } + } + + if (!this._currLatInterval) { + try { + for (var idx in this.options.latInterval) { + var dict = this.options.latInterval[idx]; + if (dict.start <= zoom) { + if (dict.end && dict.end >= zoom) { + this._currLatInterval = dict.interval; + break; + } + } + } + } + catch(e) { + this._currLatInterval = 0; + } + } + }, + + __draw: function(label) { + function _parse_px_to_int(txt) { + if (txt.length > 2) { + if (txt.charAt(txt.length-2) == 'p') { + txt = txt.substr(0, txt.length-2); + } + } + try { + return parseInt(txt, 10); + } + catch(e) {} + return 0; + }; + + var canvas = this._canvas, + map = this._map, + curvedLon = this.options.lngLineCurved, + curvedLat = this.options.latLineCurved; + + if (L.Browser.canvas && map) { + if (!this._currLngInterval || !this._currLatInterval) { + this.__calcInterval(); + } + + var latInterval = this._currLatInterval, + lngInterval = this._currLngInterval; + + var ctx = canvas.getContext('2d'); + ctx.clearRect(0, 0, canvas.width, canvas.height); + ctx.lineWidth = this.options.weight; + ctx.strokeStyle = this.options.color; + ctx.fillStyle = this.options.fontColor; + + if (this.options.font) { + ctx.font = this.options.font; + } + var txtWidth = ctx.measureText('0').width; + var txtHeight = 12; + try { + var _font_size = ctx.font.split(' ')[0]; + txtHeight = _parse_px_to_int(_font_size); + } + catch(e) {} + + var ww = canvas.width, + hh = canvas.height; + + var lt = map.containerPointToLatLng(L.point(0, 0)); + var rt = map.containerPointToLatLng(L.point(ww, 0)); + var rb = map.containerPointToLatLng(L.point(ww, hh)); + + var _lat_b = rb.lat, + _lat_t = lt.lat; + var _lon_l = lt.lng, + _lon_r = rt.lng; + + var _point_per_lat = (_lat_t - _lat_b) / (hh * 0.2); + if (_point_per_lat < 1) { _point_per_lat = 1; } + if (_lat_b < -90) { + _lat_b = -90; + } + else { + _lat_b = parseInt(_lat_b - _point_per_lat, 10); + } + + if (_lat_t > 90) { + _lat_t = 90; + } + else { + _lat_t = parseInt(_lat_t + _point_per_lat, 10); + } + + var _point_per_lon = (_lon_r - _lon_l) / (ww * 0.2); + if (_point_per_lon < 1) { _point_per_lon = 1; } + if (_lon_l > 0 && _lon_r < 0) { + _lon_r += 360; + } + _lon_r = parseInt(_lon_r + _point_per_lon, 10); + _lon_l = parseInt(_lon_l - _point_per_lon, 10); + + var ll, latstr, lngstr, _lon_delta = 0.5; + function __draw_lat_line(self, lat_tick) { + ll = map.latLngToContainerPoint(L.latLng(lat_tick, _lon_l)); + latstr = self.__format_lat(lat_tick); + txtWidth = ctx.measureText(latstr).width; + + if (curvedLat) { + if (typeof(curvedLat) == 'number') { + _lon_delta = curvedLat; + } + + var __lon_left = _lon_l, __lon_right = _lon_r; + if (ll.x > 0) { + var __lon_left = map.containerPointToLatLng(L.point(0, ll.y)); + __lon_left = __lon_left.lng - _point_per_lon; + ll.x = 0; + } + var rr = map.latLngToContainerPoint(L.latLng(lat_tick, __lon_right)); + if (rr.x < ww) { + __lon_right = map.containerPointToLatLng(L.point(ww, rr.y)); + __lon_right = __lon_right.lng + _point_per_lon; + if (__lon_left > 0 && __lon_right < 0) { + __lon_right += 360; + } + } + + ctx.beginPath(); + ctx.moveTo(ll.x, ll.y); + var _prev_p = null; + for (var j=__lon_left; j<=__lon_right; j+=_lon_delta) { + rr = map.latLngToContainerPoint(L.latLng(lat_tick, j)); + ctx.lineTo(rr.x, rr.y); + + if (self.options.showLabel && label && _prev_p != null) { + if (_prev_p.x < 0 && rr.x >= 0) { + var _s = (rr.x - 0) / (rr.x - _prev_p.x); + var _y = rr.y - ((rr.y - _prev_p.y) * _s); + ctx.fillText(latstr, 0, _y + (txtHeight/2)); + } + else if (_prev_p.x <= (ww-txtWidth) && rr.x > (ww-txtWidth)) { + var _s = (rr.x - ww) / (rr.x - _prev_p.x); + var _y = rr.y - ((rr.y - _prev_p.y) * _s); + ctx.fillText(latstr, ww-txtWidth, _y + (txtHeight/2)-2); + } + } + + _prev_p = {x:rr.x, y:rr.y, lon:j, lat:i}; + } + ctx.stroke(); + } + else { + var __lon_right = _lon_r; + var rr = map.latLngToContainerPoint(L.latLng(lat_tick, __lon_right)); + if (curvedLon) { + __lon_right = map.containerPointToLatLng(L.point(0, rr.y)); + __lon_right = __lon_right.lng; + rr = map.latLngToContainerPoint(L.latLng(lat_tick, __lon_right)); + + var __lon_left = map.containerPointToLatLng(L.point(ww, rr.y)); + __lon_left = __lon_left.lng; + ll = map.latLngToContainerPoint(L.latLng(lat_tick, __lon_left)); + } + + ctx.beginPath(); + ctx.moveTo(ll.x+1, ll.y); + ctx.lineTo(rr.x-1, rr.y); + ctx.stroke(); + if (self.options.showLabel && label) { + var _yy = ll.y + (txtHeight/2)-2; + ctx.fillText(latstr, 0, _yy); + ctx.fillText(latstr, ww-txtWidth, _yy); + } + } + }; + + if (latInterval > 0) { + for (var i=latInterval; i<=_lat_t; i+=latInterval) { + if (i >= _lat_b) { + __draw_lat_line(this, i); + } + } + for (var i=0; i>=_lat_b; i-=latInterval) { + if (i <= _lat_t) { + __draw_lat_line(this, i); + } + } + } + + function __draw_lon_line(self, lon_tick) { + lngstr = self.__format_lng(lon_tick); + txtWidth = ctx.measureText(lngstr).width; + var bb = map.latLngToContainerPoint(L.latLng(_lat_b, lon_tick)); + + if (curvedLon) { + if (typeof(curvedLon) == 'number') { + _lat_delta = curvedLon; + } + + ctx.beginPath(); + ctx.moveTo(bb.x, bb.y); + var _prev_p = null; + for (var j=_lat_b; j<_lat_t; j+=_lat_delta) { + var tt = map.latLngToContainerPoint(L.latLng(j, lon_tick)); + ctx.lineTo(tt.x, tt.y); + + if (self.options.showLabel && label && _prev_p != null) { + if (_prev_p.y > 8 && tt.y <= 8) { + ctx.fillText(lngstr, tt.x - (txtWidth/2), txtHeight); + } + else if (_prev_p.y >= hh && tt.y < hh) { + ctx.fillText(lngstr, tt.x - (txtWidth/2), hh-2); + } + } + + _prev_p = {x:tt.x, y:tt.y, lon:lon_tick, lat:j}; + } + ctx.stroke(); + } + else { + var __lat_top = _lat_t; + var tt = map.latLngToContainerPoint(L.latLng(__lat_top, lon_tick)); + if (curvedLat) { + __lat_top = map.containerPointToLatLng(L.point(tt.x, 0)); + __lat_top = __lat_top.lat; + if (__lat_top > 90) { __lat_top = 90; } + tt = map.latLngToContainerPoint(L.latLng(__lat_top, lon_tick)); + + var __lat_bottom = map.containerPointToLatLng(L.point(bb.x, hh)); + __lat_bottom = __lat_bottom.lat; + if (__lat_bottom < -90) { __lat_bottom = -90; } + bb = map.latLngToContainerPoint(L.latLng(__lat_bottom, lon_tick)); + } + + ctx.beginPath(); + ctx.moveTo(tt.x, tt.y+1); + ctx.lineTo(bb.x, bb.y-1); + ctx.stroke(); + + if (self.options.showLabel && label) { + ctx.fillText(lngstr, tt.x - (txtWidth/2), txtHeight+1); + ctx.fillText(lngstr, bb.x - (txtWidth/2), hh-3); + } + } + }; + + if (lngInterval > 0) { + for (var i=lngInterval; i<=_lon_r; i+=lngInterval) { + if (i >= _lon_l) { + __draw_lon_line(this, i); + } + } + for (var i=0; i>=_lon_l; i-=lngInterval) { + if (i <= _lon_r) { + __draw_lon_line(this, i); + } + } + } + } + } + +}); + +L.latlngGraticule = function (options) { + return new L.LatLngGraticule(options); +}; diff --git a/inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster-src.js b/inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster-src.js index 983f58e09..c725854ad 100644 --- a/inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster-src.js +++ b/inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster-src.js @@ -1,7 +1,7 @@ /* Leaflet.markercluster, Provides Beautiful Animated Marker Clustering functionality for Leaflet, a JS library for interactive maps. https://github.com/Leaflet/Leaflet.markercluster - (c) 2012-2013, Dave Leaver, smartrak + (c) 2012-2017, Dave Leaver */ (function (window, document, undefined) {/* * L.MarkerClusterGroup extends L.FeatureGroup by clustering the markers contained within @@ -12,6 +12,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({ options: { maxClusterRadius: 80, //A cluster will cover at most this many pixels from its center iconCreateFunction: null, + clusterPane: L.Marker.prototype.options.pane, spiderfyOnMaxZoom: true, showCoverageOnHover: true, @@ -677,7 +678,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({ _removeFromGridUnclustered: function (marker, z) { var map = this._map, gridUnclustered = this._gridUnclustered, - minZoom = this._map.getMinZoom(); + minZoom = Math.floor(this._map.getMinZoom()); for (; z >= minZoom; z--) { if (!gridUnclustered[z].removeObject(marker, map.project(marker.getLatLng(), z))) { @@ -725,7 +726,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({ gridUnclustered = this._gridUnclustered, fg = this._featureGroup, map = this._map, - minZoom = this._map.getMinZoom(); + minZoom = Math.floor(this._map.getMinZoom()); //Remove the marker from distance clusters it might be in if (removeFromDistanceGrid) { @@ -918,7 +919,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({ var newBounds = this._getExpandedVisibleBounds(); - this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, this._map.getMinZoom(), this._zoom, newBounds); + this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, Math.floor(this._map.getMinZoom()), this._zoom, newBounds); this._topClusterLevel._recursivelyAddChildrenToMap(null, Math.round(this._map._zoom), newBounds); this._currentShownBounds = newBounds; @@ -926,8 +927,8 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({ }, _generateInitialClusters: function () { - var maxZoom = this._map.getMaxZoom(), - minZoom = this._map.getMinZoom(), + var maxZoom = Math.ceil(this._map.getMaxZoom()), + minZoom = Math.floor(this._map.getMinZoom()), radius = this.options.maxClusterRadius, radiusFn = radius; @@ -938,7 +939,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({ radiusFn = function () { return radius; }; } - if (this.options.disableClusteringAtZoom) { + if (this.options.disableClusteringAtZoom !== null) { maxZoom = this.options.disableClusteringAtZoom - 1; } this._maxZoom = maxZoom; @@ -959,7 +960,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({ _addLayer: function (layer, zoom) { var gridClusters = this._gridClusters, gridUnclustered = this._gridUnclustered, - minZoom = this._map.getMinZoom(), + minZoom = Math.floor(this._map.getMinZoom()), markerPoint, z; if (this.options.singleMarkerMode) { @@ -1058,7 +1059,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({ if (this._zoom < mapZoom && this._currentShownBounds.intersects(this._getExpandedVisibleBounds())) { //Zoom in, split this._animationStart(); //Remove clusters now off screen - this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, this._map.getMinZoom(), this._zoom, this._getExpandedVisibleBounds()); + this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, Math.floor(this._map.getMinZoom()), this._zoom, this._getExpandedVisibleBounds()); this._animationZoomIn(this._zoom, mapZoom); @@ -1182,14 +1183,14 @@ L.MarkerClusterGroup.include({ //Do nothing... }, _animationZoomIn: function (previousZoomLevel, newZoomLevel) { - this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, this._map.getMinZoom(), previousZoomLevel); + this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, Math.floor(this._map.getMinZoom()), previousZoomLevel); this._topClusterLevel._recursivelyAddChildrenToMap(null, newZoomLevel, this._getExpandedVisibleBounds()); //We didn't actually animate, but we use this event to mean "clustering animations have finished" this.fire('animationend'); }, _animationZoomOut: function (previousZoomLevel, newZoomLevel) { - this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, this._map.getMinZoom(), previousZoomLevel); + this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, Math.floor(this._map.getMinZoom()), previousZoomLevel); this._topClusterLevel._recursivelyAddChildrenToMap(null, newZoomLevel, this._getExpandedVisibleBounds()); //We didn't actually animate, but we use this event to mean "clustering animations have finished" @@ -1210,7 +1211,7 @@ L.MarkerClusterGroup.include({ _animationZoomIn: function (previousZoomLevel, newZoomLevel) { var bounds = this._getExpandedVisibleBounds(), fg = this._featureGroup, - minZoom = this._map.getMinZoom(), + minZoom = Math.floor(this._map.getMinZoom()), i; this._ignoreMove = true; @@ -1281,7 +1282,7 @@ L.MarkerClusterGroup.include({ //Need to add markers for those that weren't on the map before but are now this._topClusterLevel._recursivelyAddChildrenToMap(null, newZoomLevel, this._getExpandedVisibleBounds()); //Remove markers that were on the map before but won't be now - this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, this._map.getMinZoom(), previousZoomLevel, this._getExpandedVisibleBounds()); + this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, Math.floor(this._map.getMinZoom()), previousZoomLevel, this._getExpandedVisibleBounds()); }, _animationAddLayer: function (layer, newCluster) { @@ -1319,7 +1320,7 @@ L.MarkerClusterGroup.include({ // Private methods for animated versions. _animationZoomOutSingle: function (cluster, previousZoomLevel, newZoomLevel) { var bounds = this._getExpandedVisibleBounds(), - minZoom = this._map.getMinZoom(); + minZoom = Math.floor(this._map.getMinZoom()); //Animate all of the markers in the clusters to move to their cluster center point cluster._recursivelyAnimateChildrenInAndAddSelfToMap(bounds, minZoom, previousZoomLevel + 1, newZoomLevel); @@ -1379,8 +1380,8 @@ L.markerClusterGroup = function (options) { L.MarkerCluster = L.Marker.extend({ initialize: function (group, zoom, a, b) { - L.Marker.prototype.initialize.call(this, a ? (a._cLatLng || a.getLatLng()) : new L.LatLng(0, 0), { icon: this }); - + L.Marker.prototype.initialize.call(this, a ? (a._cLatLng || a.getLatLng()) : new L.LatLng(0, 0), + { icon: this, pane: group.options.clusterPane }); this._group = group; this._zoom = zoom; @@ -1422,7 +1423,7 @@ L.MarkerCluster = L.Marker.extend({ }, //Zoom to the minimum of showing all of the child markers, or the extents of this cluster - zoomToBounds: function () { + zoomToBounds: function (fitBoundsOptions) { var childClusters = this._childClusters.slice(), map = this._group._map, boundsZoom = map.getBoundsZoom(this._bounds), @@ -1445,7 +1446,7 @@ L.MarkerCluster = L.Marker.extend({ } else if (boundsZoom <= mapZoom) { //If fitBounds wouldn't zoom us down, zoom us down instead this._group._map.setView(this._latlng, mapZoom + 1); } else { - this._group._map.fitBounds(this._bounds); + this._group._map.fitBounds(this._bounds, fitBoundsOptions); } }, @@ -1897,7 +1898,8 @@ L.DistanceGrid.prototype = { for (k = 0, len = cell.length; k < len; k++) { obj = cell[k]; dist = this._sqDist(objectPoint[L.Util.stamp(obj)], point); - if (dist < closestDistSq) { + if (dist < closestDistSq || + dist <= closestDistSq && closest === null) { closestDistSq = dist; closest = obj; } @@ -1910,7 +1912,8 @@ L.DistanceGrid.prototype = { }, _getCoord: function (x) { - return Math.floor(x / this._cellSize); + var coord = Math.floor(x / this._cellSize); + return isFinite(coord) ? coord : x; }, _sqDist: function (p, p2) { diff --git a/inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster.freezable-src.js b/inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster.freezable-src.js index 5f06cfedb..192eb729d 100644 --- a/inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster.freezable-src.js +++ b/inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster.freezable-src.js @@ -1,11 +1,27 @@ +/** + * Leaflet.MarkerCluster.Freezable 1.0.0+9db80a3 + * Sub-plugin for Leaflet.markercluster plugin; adds the ability to freeze clusters at a specified zoom. + * (c) 2015-2016 Boris Seang + * License MIT + */ +(function (root, factory) { + if (typeof define === "function" && define.amd) { + define(["leaflet"], factory); + } else if (typeof module === "object" && module.exports) { + factory(require("leaflet")); + } else { + factory(root.L); + } +}(this, function (L, undefined) { + L.MarkerClusterGroup.include({ - _originalOnAdd: L.MarkerClusterGroup.prototype.onAdd, + _originalOnAddFreezable: L.MarkerClusterGroup.prototype.onAdd, onAdd: function (map) { var frozenZoom = this._zoom; - this._originalOnAdd(map); + this._originalOnAddFreezable(map); if (this._frozen) { @@ -151,7 +167,10 @@ L.MarkerClusterGroup.include({ // Make as if we had instantly zoomed in from previousZoom to targetZoom. this._animationStart(); this._topClusterLevel._recursivelyRemoveChildrenFromMap( - this._currentShownBounds, previousZoom, this._getExpandedVisibleBounds() + this._currentShownBounds, + this._map.getMinZoom(), // New 2nd argument added in Leaflet.markercluster 1.0.4 + previousZoom, + this._getExpandedVisibleBounds() ); this._animationZoomIn(previousZoom, targetZoom); @@ -200,6 +219,9 @@ L.MarkerClusterGroup.include({ c._addToMap(); } ); + + // Record new bounds so that newly added markers are properly displayed. + this._currentShownBounds = newBounds; }, _originalZoomOrSpiderfy: L.MarkerClusterGroup.prototype._zoomOrSpiderfy, @@ -216,3 +238,9 @@ L.MarkerClusterGroup.include({ } }); + + + +})); + +//# sourceMappingURL=leaflet.markercluster.freezable-src.map \ No newline at end of file diff --git a/inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster.freezable.js b/inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster.freezable.js new file mode 100644 index 000000000..093a72a1a --- /dev/null +++ b/inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster.freezable.js @@ -0,0 +1,6 @@ +/*! + Leaflet.MarkerCluster.Freezable 1.0.0+9db80a3 + (c) 2015-2016 Boris Seang + License MIT + */ +!function(e,i){"function"==typeof define&&define.amd?define(["leaflet"],i):i("object"==typeof module&&module.exports?require("leaflet"):e.L)}(this,function(e,i){e.MarkerClusterGroup.include({_originalOnAddFreezable:e.MarkerClusterGroup.prototype.onAdd,onAdd:function(e){var i=this._zoom;this._originalOnAddFreezable(e),this._frozen&&(i>=0&&i!==this._zoom&&(this._featureGroup.clearLayers(),this._zoom=i,this.addLayers([])),e.off("zoomend",this._zoomEnd,this),e.off("moveend",this._moveEnd,this),e.on("zoomend moveend",this._viewChangeEndNotClustering,this))},_originalOnRemove:e.MarkerClusterGroup.prototype.onRemove,onRemove:function(e){e.off("zoomend moveend",this._viewChangeEndNotClustering,this),this._originalOnRemove(e)},disableClustering:function(){return this.freezeAtZoom(this._maxZoom+1)},disableClusteringKeepSpiderfy:function(){return this.freezeAtZoom(this._maxZoom)},enableClustering:function(){return this.unfreeze()},unfreeze:function(){return this.freezeAtZoom(!1)},freezeAtZoom:function(e){this._processQueue();var o=this._map;e===i||e===!0||e!==e?e=o?Math.round(o.getZoom()):-1:"max"===e?e=this._maxZoom+1:"maxKeepSpiderfy"===e&&(e=this._maxZoom);var t="number"==typeof e;if(this._frozen){if(!t)return this._unfreeze(),this}else{if(!t)return this;this._initiateFreeze()}return this._artificialZoomSafe(this._zoom,e),this},_initiateFreeze:function(){var e=this._map;this._frozen=!0,e&&(e.off("zoomend",this._zoomEnd,this),e.off("moveend",this._moveEnd,this),e.on("zoomend moveend",this._viewChangeEndNotClustering,this))},_unfreeze:function(){var e=this._map;this._frozen=!1,e&&(e.off("zoomend moveend",this._viewChangeEndNotClustering,this),e.on("zoomend",this._zoomEnd,this),e.on("moveend",this._moveEnd,this),this._executeAfterUnspiderfy(function(){this._zoomEnd()},this))},_executeAfterUnspiderfy:function(e,i){return this._unspiderfy&&this._spiderfied?(this.once("animationend",function(){e.call(i)}),void this._unspiderfy()):void e.call(i)},_artificialZoomSafe:function(e,i){this._zoom=i,this._map&&e!==i&&this._executeAfterUnspiderfy(function(){this._artificialZoom(e,i)},this)},_artificialZoom:function(e,i){ei&&(this._animationStart(),this._animationZoomOut(e,i))},_viewChangeEndNotClustering:function(){var e=this._featureGroup,i=this._getExpandedVisibleBounds(),o=this._zoom;e.eachLayer(function(t){!i.contains(t._latlng)&&t.__parent&&t.__parent._zoom=i;)t=t.__parent;return this._currentShownBounds.contains(t.getLatLng())&&(this.options.animateAddingMarkers?this._animationAddLayer(e,t):this._animationAddLayerNonAnimated(e,t)),this},removeLayer:function(e){return e instanceof L.LayerGroup?this.removeLayers([e]):e.getLatLng?this._map?e.__parent?(this._unspiderfy&&(this._unspiderfy(),this._unspiderfyLayer(e)),this._removeLayer(e,!0),this.fire("layerremove",{layer:e}),this._topClusterLevel._recalculateBounds(),this._refreshClustersIcons(),e.off(this._childMarkerEventHandlers,this),this._featureGroup.hasLayer(e)&&(this._featureGroup.removeLayer(e),e.clusterShow&&e.clusterShow()),this):this:(!this._arraySplice(this._needsClustering,e)&&this.hasLayer(e)&&this._needsRemoving.push({layer:e,latlng:e._latlng}),this.fire("layerremove",{layer:e}),this):(this._nonPointGroup.removeLayer(e),this.fire("layerremove",{layer:e}),this)},addLayers:function(e,t){if(!L.Util.isArray(e))return this.addLayer(e);var i,n=this._featureGroup,r=this._nonPointGroup,s=this.options.chunkedLoading,o=this.options.chunkInterval,a=this.options.chunkProgress,h=e.length,l=0,_=!0;if(this._map){var u=(new Date).getTime(),d=L.bind(function(){for(var c=(new Date).getTime();h>l;l++){if(s&&0===l%200){var p=(new Date).getTime()-c;if(p>o)break}if(i=e[l],i instanceof L.LayerGroup)_&&(e=e.slice(),_=!1),this._extractNonGroupLayers(i,e),h=e.length;else if(i.getLatLng){if(!this.hasLayer(i)&&(this._addLayer(i,this._maxZoom),t||this.fire("layeradd",{layer:i}),i.__parent&&2===i.__parent.getChildCount())){var f=i.__parent.getAllChildMarkers(),m=f[0]===i?f[1]:f[0];n.removeLayer(m)}}else r.addLayer(i),t||this.fire("layeradd",{layer:i})}a&&a(l,h,(new Date).getTime()-u),l===h?(this._topClusterLevel._recalculateBounds(),this._refreshClustersIcons(),this._topClusterLevel._recursivelyAddChildrenToMap(null,this._zoom,this._currentShownBounds)):setTimeout(d,this.options.chunkDelay)},this);d()}else for(var c=this._needsClustering;h>l;l++)i=e[l],i instanceof L.LayerGroup?(_&&(e=e.slice(),_=!1),this._extractNonGroupLayers(i,e),h=e.length):i.getLatLng?this.hasLayer(i)||c.push(i):r.addLayer(i);return this},removeLayers:function(e){var t,i,n=e.length,r=this._featureGroup,s=this._nonPointGroup,o=!0;if(!this._map){for(t=0;n>t;t++)i=e[t],i instanceof L.LayerGroup?(o&&(e=e.slice(),o=!1),this._extractNonGroupLayers(i,e),n=e.length):(this._arraySplice(this._needsClustering,i),s.removeLayer(i),this.hasLayer(i)&&this._needsRemoving.push({layer:i,latlng:i._latlng}),this.fire("layerremove",{layer:i}));return this}if(this._unspiderfy){this._unspiderfy();var a=e.slice(),h=n;for(t=0;h>t;t++)i=a[t],i instanceof L.LayerGroup?(this._extractNonGroupLayers(i,a),h=a.length):this._unspiderfyLayer(i)}for(t=0;n>t;t++)i=e[t],i instanceof L.LayerGroup?(o&&(e=e.slice(),o=!1),this._extractNonGroupLayers(i,e),n=e.length):i.__parent?(this._removeLayer(i,!0,!0),this.fire("layerremove",{layer:i}),r.hasLayer(i)&&(r.removeLayer(i),i.clusterShow&&i.clusterShow())):(s.removeLayer(i),this.fire("layerremove",{layer:i}));return this._topClusterLevel._recalculateBounds(),this._refreshClustersIcons(),this._topClusterLevel._recursivelyAddChildrenToMap(null,this._zoom,this._currentShownBounds),this},clearLayers:function(){return this._map||(this._needsClustering=[],delete this._gridClusters,delete this._gridUnclustered),this._noanimationUnspiderfy&&this._noanimationUnspiderfy(),this._featureGroup.clearLayers(),this._nonPointGroup.clearLayers(),this.eachLayer(function(e){e.off(this._childMarkerEventHandlers,this),delete e.__parent},this),this._map&&this._generateInitialClusters(),this},getBounds:function(){var e=new L.LatLngBounds;this._topClusterLevel&&e.extend(this._topClusterLevel._bounds);for(var t=this._needsClustering.length-1;t>=0;t--)e.extend(this._needsClustering[t].getLatLng());return e.extend(this._nonPointGroup.getBounds()),e},eachLayer:function(e,t){var i,n,r,s=this._needsClustering.slice(),o=this._needsRemoving;for(this._topClusterLevel&&this._topClusterLevel.getAllChildMarkers(s),n=s.length-1;n>=0;n--){for(i=!0,r=o.length-1;r>=0;r--)if(o[r].layer===s[n]){i=!1;break}i&&e.call(t,s[n])}this._nonPointGroup.eachLayer(e,t)},getLayers:function(){var e=[];return this.eachLayer(function(t){e.push(t)}),e},getLayer:function(e){var t=null;return e=parseInt(e,10),this.eachLayer(function(i){L.stamp(i)===e&&(t=i)}),t},hasLayer:function(e){if(!e)return!1;var t,i=this._needsClustering;for(t=i.length-1;t>=0;t--)if(i[t]===e)return!0;for(i=this._needsRemoving,t=i.length-1;t>=0;t--)if(i[t].layer===e)return!1;return!(!e.__parent||e.__parent._group!==this)||this._nonPointGroup.hasLayer(e)},zoomToShowLayer:function(e,t){"function"!=typeof t&&(t=function(){});var i=function(){!e._icon&&!e.__parent._icon||this._inZoomAnimation||(this._map.off("moveend",i,this),this.off("animationend",i,this),e._icon?t():e.__parent._icon&&(this.once("spiderfied",t,this),e.__parent.spiderfy()))};e._icon&&this._map.getBounds().contains(e.getLatLng())?t():e.__parent._zoomt;t++)n=this._needsRemoving[t],n.newlatlng=n.layer._latlng,n.layer._latlng=n.latlng;for(t=0,i=this._needsRemoving.length;i>t;t++)n=this._needsRemoving[t],this._removeLayer(n.layer,!0),n.layer._latlng=n.newlatlng;this._needsRemoving=[],this._zoom=Math.round(this._map._zoom),this._currentShownBounds=this._getExpandedVisibleBounds(),this._map.on("zoomend",this._zoomEnd,this),this._map.on("moveend",this._moveEnd,this),this._spiderfierOnAdd&&this._spiderfierOnAdd(),this._bindEvents(),i=this._needsClustering,this._needsClustering=[],this.addLayers(i,!0)},onRemove:function(e){e.off("zoomend",this._zoomEnd,this),e.off("moveend",this._moveEnd,this),this._unbindEvents(),this._map._mapPane.className=this._map._mapPane.className.replace(" leaflet-cluster-anim",""),this._spiderfierOnRemove&&this._spiderfierOnRemove(),delete this._maxLat,this._hideCoverage(),this._featureGroup.remove(),this._nonPointGroup.remove(),this._featureGroup.clearLayers(),this._map=null},getVisibleParent:function(e){for(var t=e;t&&!t._icon;)t=t.__parent;return t||null},_arraySplice:function(e,t){for(var i=e.length-1;i>=0;i--)if(e[i]===t)return e.splice(i,1),!0},_removeFromGridUnclustered:function(e,t){for(var i=this._map,n=this._gridUnclustered,r=this._map.getMinZoom();t>=r&&n[t].removeObject(e,i.project(e.getLatLng(),t));t--);},_childMarkerDragStart:function(e){e.target.__dragStart=e.target._latlng},_childMarkerMoved:function(e){if(!this._ignoreMove&&!e.target.__dragStart){var t=e.target._popup&&e.target._popup.isOpen();this._moveChild(e.target,e.oldLatLng,e.latlng),t&&e.target.openPopup()}},_moveChild:function(e,t,i){e._latlng=t,this.removeLayer(e),e._latlng=i,this.addLayer(e)},_childMarkerDragEnd:function(e){e.target.__dragStart&&this._moveChild(e.target,e.target.__dragStart,e.target._latlng),delete e.target.__dragStart},_removeLayer:function(e,t,i){var n=this._gridClusters,r=this._gridUnclustered,s=this._featureGroup,o=this._map,a=this._map.getMinZoom();t&&this._removeFromGridUnclustered(e,this._maxZoom);var h,l=e.__parent,_=l._markers;for(this._arraySplice(_,e);l&&(l._childCount--,l._boundsNeedUpdate=!0,!(l._zoomt?"small":100>t?"medium":"large",new L.DivIcon({html:"
"+t+"
",className:"marker-cluster"+i,iconSize:new L.Point(40,40)})},_bindEvents:function(){var e=this._map,t=this.options.spiderfyOnMaxZoom,i=this.options.showCoverageOnHover,n=this.options.zoomToBoundsOnClick;(t||n)&&this.on("clusterclick",this._zoomOrSpiderfy,this),i&&(this.on("clustermouseover",this._showCoverage,this),this.on("clustermouseout",this._hideCoverage,this),e.on("zoomend",this._hideCoverage,this))},_zoomOrSpiderfy:function(e){for(var t=e.layer,i=t;1===i._childClusters.length;)i=i._childClusters[0];i._zoom===this._maxZoom&&i._childCount===t._childCount&&this.options.spiderfyOnMaxZoom?t.spiderfy():this.options.zoomToBoundsOnClick&&t.zoomToBounds(),e.originalEvent&&13===e.originalEvent.keyCode&&this._map._container.focus()},_showCoverage:function(e){var t=this._map;this._inZoomAnimation||(this._shownPolygon&&t.removeLayer(this._shownPolygon),e.layer.getChildCount()>2&&e.layer!==this._spiderfied&&(this._shownPolygon=new L.Polygon(e.layer.getConvexHull(),this.options.polygonOptions),t.addLayer(this._shownPolygon)))},_hideCoverage:function(){this._shownPolygon&&(this._map.removeLayer(this._shownPolygon),this._shownPolygon=null)},_unbindEvents:function(){var e=this.options.spiderfyOnMaxZoom,t=this.options.showCoverageOnHover,i=this.options.zoomToBoundsOnClick,n=this._map;(e||i)&&this.off("clusterclick",this._zoomOrSpiderfy,this),t&&(this.off("clustermouseover",this._showCoverage,this),this.off("clustermouseout",this._hideCoverage,this),n.off("zoomend",this._hideCoverage,this))},_zoomEnd:function(){this._map&&(this._mergeSplitClusters(),this._zoom=Math.round(this._map._zoom),this._currentShownBounds=this._getExpandedVisibleBounds())},_moveEnd:function(){if(!this._inZoomAnimation){var e=this._getExpandedVisibleBounds();this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds,this._map.getMinZoom(),this._zoom,e),this._topClusterLevel._recursivelyAddChildrenToMap(null,Math.round(this._map._zoom),e),this._currentShownBounds=e}},_generateInitialClusters:function(){var e=this._map.getMaxZoom(),t=this._map.getMinZoom(),i=this.options.maxClusterRadius,n=i;"function"!=typeof i&&(n=function(){return i}),this.options.disableClusteringAtZoom&&(e=this.options.disableClusteringAtZoom-1),this._maxZoom=e,this._gridClusters={},this._gridUnclustered={};for(var r=e;r>=t;r--)this._gridClusters[r]=new L.DistanceGrid(n(r)),this._gridUnclustered[r]=new L.DistanceGrid(n(r));this._topClusterLevel=new this._markerCluster(this,t-1)},_addLayer:function(e,t){var i,n,r=this._gridClusters,s=this._gridUnclustered,o=this._map.getMinZoom();for(this.options.singleMarkerMode&&this._overrideMarkerIcon(e),e.on(this._childMarkerEventHandlers,this);t>=o;t--){i=this._map.project(e.getLatLng(),t);var a=r[t].getNearObject(i);if(a)return a._addChild(e),e.__parent=a,void 0;if(a=s[t].getNearObject(i)){var h=a.__parent;h&&this._removeLayer(a,!1);var l=new this._markerCluster(this,t,a,e);r[t].addObject(l,this._map.project(l._cLatLng,t)),a.__parent=l,e.__parent=l;var _=l;for(n=t-1;n>h._zoom;n--)_=new this._markerCluster(this,n,_),r[n].addObject(_,this._map.project(a.getLatLng(),n));return h._addChild(_),this._removeFromGridUnclustered(a,t),void 0}s[t].addObject(e,i)}this._topClusterLevel._addChild(e),e.__parent=this._topClusterLevel},_refreshClustersIcons:function(){this._featureGroup.eachLayer(function(e){e instanceof L.MarkerCluster&&e._iconNeedsUpdate&&e._updateIcon()})},_enqueue:function(e){this._queue.push(e),this._queueTimeout||(this._queueTimeout=setTimeout(L.bind(this._processQueue,this),300))},_processQueue:function(){for(var e=0;ee?(this._animationStart(),this._animationZoomOut(this._zoom,e)):this._moveEnd()},_getExpandedVisibleBounds:function(){return this.options.removeOutsideVisibleBounds?L.Browser.mobile?this._checkBoundsMaxLat(this._map.getBounds()):this._checkBoundsMaxLat(this._map.getBounds().pad(1)):this._mapBoundsInfinite},_checkBoundsMaxLat:function(e){var t=this._maxLat;return t!==i&&(e.getNorth()>=t&&(e._northEast.lat=1/0),e.getSouth()<=-t&&(e._southWest.lat=-1/0)),e},_animationAddLayerNonAnimated:function(e,t){if(t===e)this._featureGroup.addLayer(e);else if(2===t._childCount){t._addToMap();var i=t.getAllChildMarkers();this._featureGroup.removeLayer(i[0]),this._featureGroup.removeLayer(i[1])}else t._updateIcon()},_extractNonGroupLayers:function(e,t){var i,n=e.getLayers(),r=0;for(t=t||[];r=0;i--)o=h[i],n.contains(o._latlng)||r.removeLayer(o)}),this._forceLayout(),this._topClusterLevel._recursivelyBecomeVisible(n,t),r.eachLayer(function(e){e instanceof L.MarkerCluster||!e._icon||e.clusterShow()}),this._topClusterLevel._recursively(n,e,t,function(e){e._recursivelyRestoreChildPositions(t)}),this._ignoreMove=!1,this._enqueue(function(){this._topClusterLevel._recursively(n,e,s,function(e){r.removeLayer(e),e.clusterShow()}),this._animationEnd()})},_animationZoomOut:function(e,t){this._animationZoomOutSingle(this._topClusterLevel,e-1,t),this._topClusterLevel._recursivelyAddChildrenToMap(null,t,this._getExpandedVisibleBounds()),this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds,this._map.getMinZoom(),e,this._getExpandedVisibleBounds())},_animationAddLayer:function(e,t){var i=this,n=this._featureGroup;n.addLayer(e),t!==e&&(t._childCount>2?(t._updateIcon(),this._forceLayout(),this._animationStart(),e._setPos(this._map.latLngToLayerPoint(t.getLatLng())),e.clusterHide(),this._enqueue(function(){n.removeLayer(e),e.clusterShow(),i._animationEnd()})):(this._forceLayout(),i._animationStart(),i._animationZoomOutSingle(t,this._map.getMaxZoom(),this._zoom)))}},_animationZoomOutSingle:function(e,t,i){var n=this._getExpandedVisibleBounds(),r=this._map.getMinZoom();e._recursivelyAnimateChildrenInAndAddSelfToMap(n,r,t+1,i);var s=this;this._forceLayout(),e._recursivelyBecomeVisible(n,i),this._enqueue(function(){if(1===e._childCount){var o=e._markers[0];this._ignoreMove=!0,o.setLatLng(o.getLatLng()),this._ignoreMove=!1,o.clusterShow&&o.clusterShow()}else e._recursively(n,i,r,function(e){e._recursivelyRemoveChildrenFromMap(n,r,t+1)});s._animationEnd()})},_animationEnd:function(){this._map&&(this._map._mapPane.className=this._map._mapPane.className.replace(" leaflet-cluster-anim","")),this._inZoomAnimation--,this.fire("animationend")},_forceLayout:function(){L.Util.falseFn(t.body.offsetWidth)}}),L.markerClusterGroup=function(e){return new L.MarkerClusterGroup(e)},L.MarkerCluster=L.Marker.extend({initialize:function(e,t,i,n){L.Marker.prototype.initialize.call(this,i?i._cLatLng||i.getLatLng():new L.LatLng(0,0),{icon:this}),this._group=e,this._zoom=t,this._markers=[],this._childClusters=[],this._childCount=0,this._iconNeedsUpdate=!0,this._boundsNeedUpdate=!0,this._bounds=new L.LatLngBounds,i&&this._addChild(i),n&&this._addChild(n)},getAllChildMarkers:function(e){e=e||[];for(var t=this._childClusters.length-1;t>=0;t--)this._childClusters[t].getAllChildMarkers(e);for(var i=this._markers.length-1;i>=0;i--)e.push(this._markers[i]);return e},getChildCount:function(){return this._childCount},zoomToBounds:function(){for(var e,t=this._childClusters.slice(),i=this._group._map,n=i.getBoundsZoom(this._bounds),r=this._zoom+1,s=i.getZoom();t.length>0&&n>r;){r++;var o=[];for(e=0;er?this._group._map.setView(this._latlng,r):s>=n?this._group._map.setView(this._latlng,s+1):this._group._map.fitBounds(this._bounds)},getBounds:function(){var e=new L.LatLngBounds;return e.extend(this._bounds),e},_updateIcon:function(){this._iconNeedsUpdate=!0,this._icon&&this.setIcon(this)},createIcon:function(){return this._iconNeedsUpdate&&(this._iconObj=this._group.options.iconCreateFunction(this),this._iconNeedsUpdate=!1),this._iconObj.createIcon()},createShadow:function(){return this._iconObj.createShadow()},_addChild:function(e,t){this._iconNeedsUpdate=!0,this._boundsNeedUpdate=!0,this._setClusterCenter(e),e instanceof L.MarkerCluster?(t||(this._childClusters.push(e),e.__parent=this),this._childCount+=e._childCount):(t||this._markers.push(e),this._childCount++),this.__parent&&this.__parent._addChild(e,!0)},_setClusterCenter:function(e){this._cLatLng||(this._cLatLng=e._cLatLng||e._latlng)},_resetBounds:function(){var e=this._bounds;e._southWest&&(e._southWest.lat=1/0,e._southWest.lng=1/0),e._northEast&&(e._northEast.lat=-1/0,e._northEast.lng=-1/0)},_recalculateBounds:function(){var e,t,i,n,r=this._markers,s=this._childClusters,o=0,a=0,h=this._childCount;if(0!==h){for(this._resetBounds(),e=0;e=0;i--)n=r[i],n._icon&&(n._setPos(t),n.clusterHide())},function(e){var i,n,r=e._childClusters;for(i=r.length-1;i>=0;i--)n=r[i],n._icon&&(n._setPos(t),n.clusterHide())})},_recursivelyAnimateChildrenInAndAddSelfToMap:function(e,t,i,n){this._recursively(e,n,t,function(r){r._recursivelyAnimateChildrenIn(e,r._group._map.latLngToLayerPoint(r.getLatLng()).round(),i),r._isSingleParent()&&i-1===n?(r.clusterShow(),r._recursivelyRemoveChildrenFromMap(e,t,i)):r.clusterHide(),r._addToMap()})},_recursivelyBecomeVisible:function(e,t){this._recursively(e,this._group._map.getMinZoom(),t,null,function(e){e.clusterShow()})},_recursivelyAddChildrenToMap:function(e,t,i){this._recursively(i,this._group._map.getMinZoom()-1,t,function(n){if(t!==n._zoom)for(var r=n._markers.length-1;r>=0;r--){var s=n._markers[r];i.contains(s._latlng)&&(e&&(s._backupLatlng=s.getLatLng(),s.setLatLng(e),s.clusterHide&&s.clusterHide()),n._group._featureGroup.addLayer(s))}},function(t){t._addToMap(e)})},_recursivelyRestoreChildPositions:function(e){for(var t=this._markers.length-1;t>=0;t--){var i=this._markers[t];i._backupLatlng&&(i.setLatLng(i._backupLatlng),delete i._backupLatlng)}if(e-1===this._zoom)for(var n=this._childClusters.length-1;n>=0;n--)this._childClusters[n]._restorePosition();else for(var r=this._childClusters.length-1;r>=0;r--)this._childClusters[r]._recursivelyRestoreChildPositions(e)},_restorePosition:function(){this._backupLatlng&&(this.setLatLng(this._backupLatlng),delete this._backupLatlng)},_recursivelyRemoveChildrenFromMap:function(e,t,i,n){var r,s;this._recursively(e,t-1,i-1,function(e){for(s=e._markers.length-1;s>=0;s--)r=e._markers[s],n&&n.contains(r._latlng)||(e._group._featureGroup.removeLayer(r),r.clusterShow&&r.clusterShow())},function(e){for(s=e._childClusters.length-1;s>=0;s--)r=e._childClusters[s],n&&n.contains(r._latlng)||(e._group._featureGroup.removeLayer(r),r.clusterShow&&r.clusterShow())})},_recursively:function(e,t,i,n,r){var s,o,a=this._childClusters,h=this._zoom;if(h>=t&&(n&&n(this),r&&h===i&&r(this)),t>h||i>h)for(s=a.length-1;s>=0;s--)o=a[s],e.intersects(o._bounds)&&o._recursively(e,t,i,n,r)},_isSingleParent:function(){return this._childClusters.length>0&&this._childClusters[0]._childCount===this._childCount}}),L.Marker.include({clusterHide:function(){return this.options.opacityWhenUnclustered=this.options.opacity||1,this.setOpacity(0)},clusterShow:function(){var e=this.setOpacity(this.options.opacity||this.options.opacityWhenUnclustered);return delete this.options.opacityWhenUnclustered,e}}),L.DistanceGrid=function(e){this._cellSize=e,this._sqCellSize=e*e,this._grid={},this._objectPoint={}},L.DistanceGrid.prototype={addObject:function(e,t){var i=this._getCoord(t.x),n=this._getCoord(t.y),r=this._grid,s=r[n]=r[n]||{},o=s[i]=s[i]||[],a=L.Util.stamp(e);this._objectPoint[a]=t,o.push(e)},updateObject:function(e,t){this.removeObject(e),this.addObject(e,t)},removeObject:function(e,t){var i,n,r=this._getCoord(t.x),s=this._getCoord(t.y),o=this._grid,a=o[s]=o[s]||{},h=a[r]=a[r]||[];for(delete this._objectPoint[L.Util.stamp(e)],i=0,n=h.length;n>i;i++)if(h[i]===e)return h.splice(i,1),1===n&&delete a[r],!0},eachObject:function(e,t){var i,n,r,s,o,a,h,l=this._grid;for(i in l){o=l[i];for(n in o)for(a=o[n],r=0,s=a.length;s>r;r++)h=e.call(t,a[r]),h&&(r--,s--)}},getNearObject:function(e){var t,i,n,r,s,o,a,h,l=this._getCoord(e.x),_=this._getCoord(e.y),u=this._objectPoint,d=this._sqCellSize,c=null;for(t=_-1;_+1>=t;t++)if(r=this._grid[t])for(i=l-1;l+1>=i;i++)if(s=r[i])for(n=0,o=s.length;o>n;n++)a=s[n],h=this._sqDist(u[L.Util.stamp(a)],e),d>h&&(d=h,c=a);return c},_getCoord:function(e){return Math.floor(e/this._cellSize)},_sqDist:function(e,t){var i=t.x-e.x,n=t.y-e.y;return i*i+n*n}},function(){L.QuickHull={getDistant:function(e,t){var i=t[1].lat-t[0].lat,n=t[0].lng-t[1].lng;return n*(e.lat-t[0].lat)+i*(e.lng-t[0].lng)},findMostDistantPointFromBaseLine:function(e,t){var i,n,r,s=0,o=null,a=[];for(i=t.length-1;i>=0;i--)n=t[i],r=this.getDistant(n,e),r>0&&(a.push(n),r>s&&(s=r,o=n));return{maxPoint:o,newPoints:a}},buildConvexHull:function(e,t){var i=[],n=this.findMostDistantPointFromBaseLine(e,t);return n.maxPoint?(i=i.concat(this.buildConvexHull([e[0],n.maxPoint],n.newPoints)),i=i.concat(this.buildConvexHull([n.maxPoint,e[1]],n.newPoints))):[e[0]]},getConvexHull:function(e){var t,i=!1,n=!1,r=!1,s=!1,o=null,a=null,h=null,l=null,_=null,u=null;for(t=e.length-1;t>=0;t--){var d=e[t];(i===!1||d.lat>i)&&(o=d,i=d.lat),(n===!1||d.latr)&&(h=d,r=d.lng),(s===!1||d.lng=0;t--)e=i[t].getLatLng(),n.push(e);return L.QuickHull.getConvexHull(n)}}),L.MarkerCluster.include({_2PI:2*Math.PI,_circleFootSeparation:25,_circleStartAngle:Math.PI/6,_spiralFootSeparation:28,_spiralLengthStart:11,_spiralLengthFactor:5,_circleSpiralSwitchover:9,spiderfy:function(){if(this._group._spiderfied!==this&&!this._group._inZoomAnimation){var e,t=this.getAllChildMarkers(),i=this._group,n=i._map,r=n.latLngToLayerPoint(this._latlng);this._group._unspiderfy(),this._group._spiderfied=this,t.length>=this._circleSpiralSwitchover?e=this._generatePointsSpiral(t.length,r):(r.y+=10,e=this._generatePointsCircle(t.length,r)),this._animationSpiderfy(t,e)}},unspiderfy:function(e){this._group._inZoomAnimation||(this._animationUnspiderfy(e),this._group._spiderfied=null)},_generatePointsCircle:function(e,t){var i,n,r=this._group.options.spiderfyDistanceMultiplier*this._circleFootSeparation*(2+e),s=r/this._2PI,o=this._2PI/e,a=[];for(a.length=e,i=e-1;i>=0;i--)n=this._circleStartAngle+i*o,a[i]=new L.Point(t.x+s*Math.cos(n),t.y+s*Math.sin(n))._round();return a},_generatePointsSpiral:function(e,t){var i,n=this._group.options.spiderfyDistanceMultiplier,r=n*this._spiralLengthStart,s=n*this._spiralFootSeparation,o=n*this._spiralLengthFactor*this._2PI,a=0,h=[];for(h.length=e,i=e-1;i>=0;i--)a+=s/r+5e-4*i,h[i]=new L.Point(t.x+r*Math.cos(a),t.y+r*Math.sin(a))._round(),r+=o/a;return h},_noanimationUnspiderfy:function(){var e,t,i=this._group,n=i._map,r=i._featureGroup,s=this.getAllChildMarkers();for(i._ignoreMove=!0,this.setOpacity(1),t=s.length-1;t>=0;t--)e=s[t],r.removeLayer(e),e._preSpiderfyLatlng&&(e.setLatLng(e._preSpiderfyLatlng),delete e._preSpiderfyLatlng),e.setZIndexOffset&&e.setZIndexOffset(0),e._spiderLeg&&(n.removeLayer(e._spiderLeg),delete e._spiderLeg);i.fire("unspiderfied",{cluster:this,markers:s}),i._ignoreMove=!1,i._spiderfied=null}}),L.MarkerClusterNonAnimated=L.MarkerCluster.extend({_animationSpiderfy:function(e,t){var i,n,r,s,o=this._group,a=o._map,h=o._featureGroup,l=this._group.options.spiderLegPolylineOptions;for(o._ignoreMove=!0,i=0;i=0;n--)h=u.layerPointToLatLng(t[n]),r=e[n],r._preSpiderfyLatlng=r._latlng,r.setLatLng(h),r.clusterShow&&r.clusterShow(),f&&(s=r._spiderLeg,o=s._path,o.style.strokeDashoffset=0,s.setStyle({opacity:g}));this.setOpacity(.3),_._ignoreMove=!1,setTimeout(function(){_._animationEnd(),_.fire("spiderfied",{cluster:l,markers:e})},200)},_animationUnspiderfy:function(e){var t,i,n,r,s,o,a=this,h=this._group,l=h._map,_=h._featureGroup,u=e?l._latLngToNewLayerPoint(this._latlng,e.zoom,e.center):l.latLngToLayerPoint(this._latlng),d=this.getAllChildMarkers(),c=L.Path.SVG;for(h._ignoreMove=!0,h._animationStart(),this.setOpacity(1),i=d.length-1;i>=0;i--)t=d[i],t._preSpiderfyLatlng&&(t.closePopup(),t.setLatLng(t._preSpiderfyLatlng),delete t._preSpiderfyLatlng,o=!0,t._setPos&&(t._setPos(u),o=!1),t.clusterHide&&(t.clusterHide(),o=!1),o&&_.removeLayer(t),c&&(n=t._spiderLeg,r=n._path,s=r.getTotalLength()+.1,r.style.strokeDashoffset=s,n.setStyle({opacity:0})));h._ignoreMove=!1,setTimeout(function(){var e=0;for(i=d.length-1;i>=0;i--)t=d[i],t._spiderLeg&&e++;for(i=d.length-1;i>=0;i--)t=d[i],t._spiderLeg&&(t.clusterShow&&t.clusterShow(),t.setZIndexOffset&&t.setZIndexOffset(0),e>1&&_.removeLayer(t),l.removeLayer(t._spiderLeg),delete t._spiderLeg);h._animationEnd(),h.fire("unspiderfied",{cluster:a,markers:d})},200)}}),L.MarkerClusterGroup.include({_spiderfied:null,unspiderfy:function(){this._unspiderfy.apply(this,arguments)},_spiderfierOnAdd:function(){this._map.on("click",this._unspiderfyWrapper,this),this._map.options.zoomAnimation&&this._map.on("zoomstart",this._unspiderfyZoomStart,this),this._map.on("zoomend",this._noanimationUnspiderfy,this),L.Browser.touch||this._map.getRenderer(this)},_spiderfierOnRemove:function(){this._map.off("click",this._unspiderfyWrapper,this),this._map.off("zoomstart",this._unspiderfyZoomStart,this),this._map.off("zoomanim",this._unspiderfyZoomAnim,this),this._map.off("zoomend",this._noanimationUnspiderfy,this),this._noanimationUnspiderfy()},_unspiderfyZoomStart:function(){this._map&&this._map.on("zoomanim",this._unspiderfyZoomAnim,this)},_unspiderfyZoomAnim:function(e){L.DomUtil.hasClass(this._map._mapPane,"leaflet-touching")||(this._map.off("zoomanim",this._unspiderfyZoomAnim,this),this._unspiderfy(e))},_unspiderfyWrapper:function(){this._unspiderfy()},_unspiderfy:function(e){this._spiderfied&&this._spiderfied.unspiderfy(e)},_noanimationUnspiderfy:function(){this._spiderfied&&this._spiderfied._noanimationUnspiderfy()},_unspiderfyLayer:function(e){e._spiderLeg&&(this._featureGroup.removeLayer(e),e.clusterShow&&e.clusterShow(),e.setZIndexOffset&&e.setZIndexOffset(0),this._map.removeLayer(e._spiderLeg),delete e._spiderLeg) -}}),L.MarkerClusterGroup.include({refreshClusters:function(e){return e?e instanceof L.MarkerClusterGroup?e=e._topClusterLevel.getAllChildMarkers():e instanceof L.LayerGroup?e=e._layers:e instanceof L.MarkerCluster?e=e.getAllChildMarkers():e instanceof L.Marker&&(e=[e]):e=this._topClusterLevel.getAllChildMarkers(),this._flagParentsIconsNeedUpdate(e),this._refreshClustersIcons(),this.options.singleMarkerMode&&this._refreshSingleMarkerModeMarkers(e),this},_flagParentsIconsNeedUpdate:function(e){var t,i;for(t in e)for(i=e[t].__parent;i;)i._iconNeedsUpdate=!0,i=i.__parent},_refreshSingleMarkerModeMarkers:function(e){var t,i;for(t in e)i=e[t],this.hasLayer(i)&&i.setIcon(this._overrideMarkerIcon(i))}}),L.Marker.include({refreshIconOptions:function(e,t){var i=this.options.icon;return L.setOptions(i,e),this.setIcon(i),t&&this.__parent&&this.__parent._group.refreshClusters(this),this}})}(window,document); \ No newline at end of file +!function(e,t,i){L.MarkerClusterGroup=L.FeatureGroup.extend({options:{maxClusterRadius:80,iconCreateFunction:null,clusterPane:L.Marker.prototype.options.pane,spiderfyOnMaxZoom:!0,showCoverageOnHover:!0,zoomToBoundsOnClick:!0,singleMarkerMode:!1,disableClusteringAtZoom:null,removeOutsideVisibleBounds:!0,animate:!0,animateAddingMarkers:!1,spiderfyDistanceMultiplier:1,spiderLegPolylineOptions:{weight:1.5,color:"#222",opacity:.5},chunkedLoading:!1,chunkInterval:200,chunkDelay:50,chunkProgress:null,polygonOptions:{}},initialize:function(e){L.Util.setOptions(this,e),this.options.iconCreateFunction||(this.options.iconCreateFunction=this._defaultIconCreateFunction),this._featureGroup=L.featureGroup(),this._featureGroup.addEventParent(this),this._nonPointGroup=L.featureGroup(),this._nonPointGroup.addEventParent(this),this._inZoomAnimation=0,this._needsClustering=[],this._needsRemoving=[],this._currentShownBounds=null,this._queue=[],this._childMarkerEventHandlers={dragstart:this._childMarkerDragStart,move:this._childMarkerMoved,dragend:this._childMarkerDragEnd};var t=L.DomUtil.TRANSITION&&this.options.animate;L.extend(this,t?this._withAnimation:this._noAnimation),this._markerCluster=t?L.MarkerCluster:L.MarkerClusterNonAnimated},addLayer:function(e){if(e instanceof L.LayerGroup)return this.addLayers([e]);if(!e.getLatLng)return this._nonPointGroup.addLayer(e),this.fire("layeradd",{layer:e}),this;if(!this._map)return this._needsClustering.push(e),this.fire("layeradd",{layer:e}),this;if(this.hasLayer(e))return this;this._unspiderfy&&this._unspiderfy(),this._addLayer(e,this._maxZoom),this.fire("layeradd",{layer:e}),this._topClusterLevel._recalculateBounds(),this._refreshClustersIcons();var t=e,i=this._zoom;if(e.__parent)for(;t.__parent._zoom>=i;)t=t.__parent;return this._currentShownBounds.contains(t.getLatLng())&&(this.options.animateAddingMarkers?this._animationAddLayer(e,t):this._animationAddLayerNonAnimated(e,t)),this},removeLayer:function(e){return e instanceof L.LayerGroup?this.removeLayers([e]):e.getLatLng?this._map?e.__parent?(this._unspiderfy&&(this._unspiderfy(),this._unspiderfyLayer(e)),this._removeLayer(e,!0),this.fire("layerremove",{layer:e}),this._topClusterLevel._recalculateBounds(),this._refreshClustersIcons(),e.off(this._childMarkerEventHandlers,this),this._featureGroup.hasLayer(e)&&(this._featureGroup.removeLayer(e),e.clusterShow&&e.clusterShow()),this):this:(!this._arraySplice(this._needsClustering,e)&&this.hasLayer(e)&&this._needsRemoving.push({layer:e,latlng:e._latlng}),this.fire("layerremove",{layer:e}),this):(this._nonPointGroup.removeLayer(e),this.fire("layerremove",{layer:e}),this)},addLayers:function(e,t){if(!L.Util.isArray(e))return this.addLayer(e);var i,n=this._featureGroup,r=this._nonPointGroup,s=this.options.chunkedLoading,o=this.options.chunkInterval,a=this.options.chunkProgress,h=e.length,l=0,u=!0;if(this._map){var _=(new Date).getTime(),d=L.bind(function(){for(var c=(new Date).getTime();h>l;l++){if(s&&0===l%200){var p=(new Date).getTime()-c;if(p>o)break}if(i=e[l],i instanceof L.LayerGroup)u&&(e=e.slice(),u=!1),this._extractNonGroupLayers(i,e),h=e.length;else if(i.getLatLng){if(!this.hasLayer(i)&&(this._addLayer(i,this._maxZoom),t||this.fire("layeradd",{layer:i}),i.__parent&&2===i.__parent.getChildCount())){var f=i.__parent.getAllChildMarkers(),m=f[0]===i?f[1]:f[0];n.removeLayer(m)}}else r.addLayer(i),t||this.fire("layeradd",{layer:i})}a&&a(l,h,(new Date).getTime()-_),l===h?(this._topClusterLevel._recalculateBounds(),this._refreshClustersIcons(),this._topClusterLevel._recursivelyAddChildrenToMap(null,this._zoom,this._currentShownBounds)):setTimeout(d,this.options.chunkDelay)},this);d()}else for(var c=this._needsClustering;h>l;l++)i=e[l],i instanceof L.LayerGroup?(u&&(e=e.slice(),u=!1),this._extractNonGroupLayers(i,e),h=e.length):i.getLatLng?this.hasLayer(i)||c.push(i):r.addLayer(i);return this},removeLayers:function(e){var t,i,n=e.length,r=this._featureGroup,s=this._nonPointGroup,o=!0;if(!this._map){for(t=0;n>t;t++)i=e[t],i instanceof L.LayerGroup?(o&&(e=e.slice(),o=!1),this._extractNonGroupLayers(i,e),n=e.length):(this._arraySplice(this._needsClustering,i),s.removeLayer(i),this.hasLayer(i)&&this._needsRemoving.push({layer:i,latlng:i._latlng}),this.fire("layerremove",{layer:i}));return this}if(this._unspiderfy){this._unspiderfy();var a=e.slice(),h=n;for(t=0;h>t;t++)i=a[t],i instanceof L.LayerGroup?(this._extractNonGroupLayers(i,a),h=a.length):this._unspiderfyLayer(i)}for(t=0;n>t;t++)i=e[t],i instanceof L.LayerGroup?(o&&(e=e.slice(),o=!1),this._extractNonGroupLayers(i,e),n=e.length):i.__parent?(this._removeLayer(i,!0,!0),this.fire("layerremove",{layer:i}),r.hasLayer(i)&&(r.removeLayer(i),i.clusterShow&&i.clusterShow())):(s.removeLayer(i),this.fire("layerremove",{layer:i}));return this._topClusterLevel._recalculateBounds(),this._refreshClustersIcons(),this._topClusterLevel._recursivelyAddChildrenToMap(null,this._zoom,this._currentShownBounds),this},clearLayers:function(){return this._map||(this._needsClustering=[],delete this._gridClusters,delete this._gridUnclustered),this._noanimationUnspiderfy&&this._noanimationUnspiderfy(),this._featureGroup.clearLayers(),this._nonPointGroup.clearLayers(),this.eachLayer(function(e){e.off(this._childMarkerEventHandlers,this),delete e.__parent},this),this._map&&this._generateInitialClusters(),this},getBounds:function(){var e=new L.LatLngBounds;this._topClusterLevel&&e.extend(this._topClusterLevel._bounds);for(var t=this._needsClustering.length-1;t>=0;t--)e.extend(this._needsClustering[t].getLatLng());return e.extend(this._nonPointGroup.getBounds()),e},eachLayer:function(e,t){var i,n,r,s=this._needsClustering.slice(),o=this._needsRemoving;for(this._topClusterLevel&&this._topClusterLevel.getAllChildMarkers(s),n=s.length-1;n>=0;n--){for(i=!0,r=o.length-1;r>=0;r--)if(o[r].layer===s[n]){i=!1;break}i&&e.call(t,s[n])}this._nonPointGroup.eachLayer(e,t)},getLayers:function(){var e=[];return this.eachLayer(function(t){e.push(t)}),e},getLayer:function(e){var t=null;return e=parseInt(e,10),this.eachLayer(function(i){L.stamp(i)===e&&(t=i)}),t},hasLayer:function(e){if(!e)return!1;var t,i=this._needsClustering;for(t=i.length-1;t>=0;t--)if(i[t]===e)return!0;for(i=this._needsRemoving,t=i.length-1;t>=0;t--)if(i[t].layer===e)return!1;return!(!e.__parent||e.__parent._group!==this)||this._nonPointGroup.hasLayer(e)},zoomToShowLayer:function(e,t){"function"!=typeof t&&(t=function(){});var i=function(){!e._icon&&!e.__parent._icon||this._inZoomAnimation||(this._map.off("moveend",i,this),this.off("animationend",i,this),e._icon?t():e.__parent._icon&&(this.once("spiderfied",t,this),e.__parent.spiderfy()))};e._icon&&this._map.getBounds().contains(e.getLatLng())?t():e.__parent._zoomt;t++)n=this._needsRemoving[t],n.newlatlng=n.layer._latlng,n.layer._latlng=n.latlng;for(t=0,i=this._needsRemoving.length;i>t;t++)n=this._needsRemoving[t],this._removeLayer(n.layer,!0),n.layer._latlng=n.newlatlng;this._needsRemoving=[],this._zoom=Math.round(this._map._zoom),this._currentShownBounds=this._getExpandedVisibleBounds(),this._map.on("zoomend",this._zoomEnd,this),this._map.on("moveend",this._moveEnd,this),this._spiderfierOnAdd&&this._spiderfierOnAdd(),this._bindEvents(),i=this._needsClustering,this._needsClustering=[],this.addLayers(i,!0)},onRemove:function(e){e.off("zoomend",this._zoomEnd,this),e.off("moveend",this._moveEnd,this),this._unbindEvents(),this._map._mapPane.className=this._map._mapPane.className.replace(" leaflet-cluster-anim",""),this._spiderfierOnRemove&&this._spiderfierOnRemove(),delete this._maxLat,this._hideCoverage(),this._featureGroup.remove(),this._nonPointGroup.remove(),this._featureGroup.clearLayers(),this._map=null},getVisibleParent:function(e){for(var t=e;t&&!t._icon;)t=t.__parent;return t||null},_arraySplice:function(e,t){for(var i=e.length-1;i>=0;i--)if(e[i]===t)return e.splice(i,1),!0},_removeFromGridUnclustered:function(e,t){for(var i=this._map,n=this._gridUnclustered,r=Math.floor(this._map.getMinZoom());t>=r&&n[t].removeObject(e,i.project(e.getLatLng(),t));t--);},_childMarkerDragStart:function(e){e.target.__dragStart=e.target._latlng},_childMarkerMoved:function(e){if(!this._ignoreMove&&!e.target.__dragStart){var t=e.target._popup&&e.target._popup.isOpen();this._moveChild(e.target,e.oldLatLng,e.latlng),t&&e.target.openPopup()}},_moveChild:function(e,t,i){e._latlng=t,this.removeLayer(e),e._latlng=i,this.addLayer(e)},_childMarkerDragEnd:function(e){e.target.__dragStart&&this._moveChild(e.target,e.target.__dragStart,e.target._latlng),delete e.target.__dragStart},_removeLayer:function(e,t,i){var n=this._gridClusters,r=this._gridUnclustered,s=this._featureGroup,o=this._map,a=Math.floor(this._map.getMinZoom());t&&this._removeFromGridUnclustered(e,this._maxZoom);var h,l=e.__parent,u=l._markers;for(this._arraySplice(u,e);l&&(l._childCount--,l._boundsNeedUpdate=!0,!(l._zoomt?"small":100>t?"medium":"large",new L.DivIcon({html:"
"+t+"
",className:"marker-cluster"+i,iconSize:new L.Point(40,40)})},_bindEvents:function(){var e=this._map,t=this.options.spiderfyOnMaxZoom,i=this.options.showCoverageOnHover,n=this.options.zoomToBoundsOnClick;(t||n)&&this.on("clusterclick",this._zoomOrSpiderfy,this),i&&(this.on("clustermouseover",this._showCoverage,this),this.on("clustermouseout",this._hideCoverage,this),e.on("zoomend",this._hideCoverage,this))},_zoomOrSpiderfy:function(e){for(var t=e.layer,i=t;1===i._childClusters.length;)i=i._childClusters[0];i._zoom===this._maxZoom&&i._childCount===t._childCount&&this.options.spiderfyOnMaxZoom?t.spiderfy():this.options.zoomToBoundsOnClick&&t.zoomToBounds(),e.originalEvent&&13===e.originalEvent.keyCode&&this._map._container.focus()},_showCoverage:function(e){var t=this._map;this._inZoomAnimation||(this._shownPolygon&&t.removeLayer(this._shownPolygon),e.layer.getChildCount()>2&&e.layer!==this._spiderfied&&(this._shownPolygon=new L.Polygon(e.layer.getConvexHull(),this.options.polygonOptions),t.addLayer(this._shownPolygon)))},_hideCoverage:function(){this._shownPolygon&&(this._map.removeLayer(this._shownPolygon),this._shownPolygon=null)},_unbindEvents:function(){var e=this.options.spiderfyOnMaxZoom,t=this.options.showCoverageOnHover,i=this.options.zoomToBoundsOnClick,n=this._map;(e||i)&&this.off("clusterclick",this._zoomOrSpiderfy,this),t&&(this.off("clustermouseover",this._showCoverage,this),this.off("clustermouseout",this._hideCoverage,this),n.off("zoomend",this._hideCoverage,this))},_zoomEnd:function(){this._map&&(this._mergeSplitClusters(),this._zoom=Math.round(this._map._zoom),this._currentShownBounds=this._getExpandedVisibleBounds())},_moveEnd:function(){if(!this._inZoomAnimation){var e=this._getExpandedVisibleBounds();this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds,Math.floor(this._map.getMinZoom()),this._zoom,e),this._topClusterLevel._recursivelyAddChildrenToMap(null,Math.round(this._map._zoom),e),this._currentShownBounds=e}},_generateInitialClusters:function(){var e=Math.ceil(this._map.getMaxZoom()),t=Math.floor(this._map.getMinZoom()),i=this.options.maxClusterRadius,n=i;"function"!=typeof i&&(n=function(){return i}),null!==this.options.disableClusteringAtZoom&&(e=this.options.disableClusteringAtZoom-1),this._maxZoom=e,this._gridClusters={},this._gridUnclustered={};for(var r=e;r>=t;r--)this._gridClusters[r]=new L.DistanceGrid(n(r)),this._gridUnclustered[r]=new L.DistanceGrid(n(r));this._topClusterLevel=new this._markerCluster(this,t-1)},_addLayer:function(e,t){var i,n,r=this._gridClusters,s=this._gridUnclustered,o=Math.floor(this._map.getMinZoom());for(this.options.singleMarkerMode&&this._overrideMarkerIcon(e),e.on(this._childMarkerEventHandlers,this);t>=o;t--){i=this._map.project(e.getLatLng(),t);var a=r[t].getNearObject(i);if(a)return a._addChild(e),e.__parent=a,void 0;if(a=s[t].getNearObject(i)){var h=a.__parent;h&&this._removeLayer(a,!1);var l=new this._markerCluster(this,t,a,e);r[t].addObject(l,this._map.project(l._cLatLng,t)),a.__parent=l,e.__parent=l;var u=l;for(n=t-1;n>h._zoom;n--)u=new this._markerCluster(this,n,u),r[n].addObject(u,this._map.project(a.getLatLng(),n));return h._addChild(u),this._removeFromGridUnclustered(a,t),void 0}s[t].addObject(e,i)}this._topClusterLevel._addChild(e),e.__parent=this._topClusterLevel},_refreshClustersIcons:function(){this._featureGroup.eachLayer(function(e){e instanceof L.MarkerCluster&&e._iconNeedsUpdate&&e._updateIcon()})},_enqueue:function(e){this._queue.push(e),this._queueTimeout||(this._queueTimeout=setTimeout(L.bind(this._processQueue,this),300))},_processQueue:function(){for(var e=0;ee?(this._animationStart(),this._animationZoomOut(this._zoom,e)):this._moveEnd()},_getExpandedVisibleBounds:function(){return this.options.removeOutsideVisibleBounds?L.Browser.mobile?this._checkBoundsMaxLat(this._map.getBounds()):this._checkBoundsMaxLat(this._map.getBounds().pad(1)):this._mapBoundsInfinite},_checkBoundsMaxLat:function(e){var t=this._maxLat;return t!==i&&(e.getNorth()>=t&&(e._northEast.lat=1/0),e.getSouth()<=-t&&(e._southWest.lat=-1/0)),e},_animationAddLayerNonAnimated:function(e,t){if(t===e)this._featureGroup.addLayer(e);else if(2===t._childCount){t._addToMap();var i=t.getAllChildMarkers();this._featureGroup.removeLayer(i[0]),this._featureGroup.removeLayer(i[1])}else t._updateIcon()},_extractNonGroupLayers:function(e,t){var i,n=e.getLayers(),r=0;for(t=t||[];r=0;i--)o=h[i],n.contains(o._latlng)||r.removeLayer(o)}),this._forceLayout(),this._topClusterLevel._recursivelyBecomeVisible(n,t),r.eachLayer(function(e){e instanceof L.MarkerCluster||!e._icon||e.clusterShow()}),this._topClusterLevel._recursively(n,e,t,function(e){e._recursivelyRestoreChildPositions(t)}),this._ignoreMove=!1,this._enqueue(function(){this._topClusterLevel._recursively(n,e,s,function(e){r.removeLayer(e),e.clusterShow()}),this._animationEnd()})},_animationZoomOut:function(e,t){this._animationZoomOutSingle(this._topClusterLevel,e-1,t),this._topClusterLevel._recursivelyAddChildrenToMap(null,t,this._getExpandedVisibleBounds()),this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds,Math.floor(this._map.getMinZoom()),e,this._getExpandedVisibleBounds())},_animationAddLayer:function(e,t){var i=this,n=this._featureGroup;n.addLayer(e),t!==e&&(t._childCount>2?(t._updateIcon(),this._forceLayout(),this._animationStart(),e._setPos(this._map.latLngToLayerPoint(t.getLatLng())),e.clusterHide(),this._enqueue(function(){n.removeLayer(e),e.clusterShow(),i._animationEnd()})):(this._forceLayout(),i._animationStart(),i._animationZoomOutSingle(t,this._map.getMaxZoom(),this._zoom)))}},_animationZoomOutSingle:function(e,t,i){var n=this._getExpandedVisibleBounds(),r=Math.floor(this._map.getMinZoom());e._recursivelyAnimateChildrenInAndAddSelfToMap(n,r,t+1,i);var s=this;this._forceLayout(),e._recursivelyBecomeVisible(n,i),this._enqueue(function(){if(1===e._childCount){var o=e._markers[0];this._ignoreMove=!0,o.setLatLng(o.getLatLng()),this._ignoreMove=!1,o.clusterShow&&o.clusterShow()}else e._recursively(n,i,r,function(e){e._recursivelyRemoveChildrenFromMap(n,r,t+1)});s._animationEnd()})},_animationEnd:function(){this._map&&(this._map._mapPane.className=this._map._mapPane.className.replace(" leaflet-cluster-anim","")),this._inZoomAnimation--,this.fire("animationend")},_forceLayout:function(){L.Util.falseFn(t.body.offsetWidth)}}),L.markerClusterGroup=function(e){return new L.MarkerClusterGroup(e)},L.MarkerCluster=L.Marker.extend({initialize:function(e,t,i,n){L.Marker.prototype.initialize.call(this,i?i._cLatLng||i.getLatLng():new L.LatLng(0,0),{icon:this,pane:e.options.clusterPane}),this._group=e,this._zoom=t,this._markers=[],this._childClusters=[],this._childCount=0,this._iconNeedsUpdate=!0,this._boundsNeedUpdate=!0,this._bounds=new L.LatLngBounds,i&&this._addChild(i),n&&this._addChild(n)},getAllChildMarkers:function(e){e=e||[];for(var t=this._childClusters.length-1;t>=0;t--)this._childClusters[t].getAllChildMarkers(e);for(var i=this._markers.length-1;i>=0;i--)e.push(this._markers[i]);return e},getChildCount:function(){return this._childCount},zoomToBounds:function(e){for(var t,i=this._childClusters.slice(),n=this._group._map,r=n.getBoundsZoom(this._bounds),s=this._zoom+1,o=n.getZoom();i.length>0&&r>s;){s++;var a=[];for(t=0;ts?this._group._map.setView(this._latlng,s):o>=r?this._group._map.setView(this._latlng,o+1):this._group._map.fitBounds(this._bounds,e)},getBounds:function(){var e=new L.LatLngBounds;return e.extend(this._bounds),e},_updateIcon:function(){this._iconNeedsUpdate=!0,this._icon&&this.setIcon(this)},createIcon:function(){return this._iconNeedsUpdate&&(this._iconObj=this._group.options.iconCreateFunction(this),this._iconNeedsUpdate=!1),this._iconObj.createIcon()},createShadow:function(){return this._iconObj.createShadow()},_addChild:function(e,t){this._iconNeedsUpdate=!0,this._boundsNeedUpdate=!0,this._setClusterCenter(e),e instanceof L.MarkerCluster?(t||(this._childClusters.push(e),e.__parent=this),this._childCount+=e._childCount):(t||this._markers.push(e),this._childCount++),this.__parent&&this.__parent._addChild(e,!0)},_setClusterCenter:function(e){this._cLatLng||(this._cLatLng=e._cLatLng||e._latlng)},_resetBounds:function(){var e=this._bounds;e._southWest&&(e._southWest.lat=1/0,e._southWest.lng=1/0),e._northEast&&(e._northEast.lat=-1/0,e._northEast.lng=-1/0)},_recalculateBounds:function(){var e,t,i,n,r=this._markers,s=this._childClusters,o=0,a=0,h=this._childCount;if(0!==h){for(this._resetBounds(),e=0;e=0;i--)n=r[i],n._icon&&(n._setPos(t),n.clusterHide())},function(e){var i,n,r=e._childClusters;for(i=r.length-1;i>=0;i--)n=r[i],n._icon&&(n._setPos(t),n.clusterHide())})},_recursivelyAnimateChildrenInAndAddSelfToMap:function(e,t,i,n){this._recursively(e,n,t,function(r){r._recursivelyAnimateChildrenIn(e,r._group._map.latLngToLayerPoint(r.getLatLng()).round(),i),r._isSingleParent()&&i-1===n?(r.clusterShow(),r._recursivelyRemoveChildrenFromMap(e,t,i)):r.clusterHide(),r._addToMap()})},_recursivelyBecomeVisible:function(e,t){this._recursively(e,this._group._map.getMinZoom(),t,null,function(e){e.clusterShow()})},_recursivelyAddChildrenToMap:function(e,t,i){this._recursively(i,this._group._map.getMinZoom()-1,t,function(n){if(t!==n._zoom)for(var r=n._markers.length-1;r>=0;r--){var s=n._markers[r];i.contains(s._latlng)&&(e&&(s._backupLatlng=s.getLatLng(),s.setLatLng(e),s.clusterHide&&s.clusterHide()),n._group._featureGroup.addLayer(s))}},function(t){t._addToMap(e)})},_recursivelyRestoreChildPositions:function(e){for(var t=this._markers.length-1;t>=0;t--){var i=this._markers[t];i._backupLatlng&&(i.setLatLng(i._backupLatlng),delete i._backupLatlng)}if(e-1===this._zoom)for(var n=this._childClusters.length-1;n>=0;n--)this._childClusters[n]._restorePosition();else for(var r=this._childClusters.length-1;r>=0;r--)this._childClusters[r]._recursivelyRestoreChildPositions(e)},_restorePosition:function(){this._backupLatlng&&(this.setLatLng(this._backupLatlng),delete this._backupLatlng)},_recursivelyRemoveChildrenFromMap:function(e,t,i,n){var r,s;this._recursively(e,t-1,i-1,function(e){for(s=e._markers.length-1;s>=0;s--)r=e._markers[s],n&&n.contains(r._latlng)||(e._group._featureGroup.removeLayer(r),r.clusterShow&&r.clusterShow())},function(e){for(s=e._childClusters.length-1;s>=0;s--)r=e._childClusters[s],n&&n.contains(r._latlng)||(e._group._featureGroup.removeLayer(r),r.clusterShow&&r.clusterShow())})},_recursively:function(e,t,i,n,r){var s,o,a=this._childClusters,h=this._zoom;if(h>=t&&(n&&n(this),r&&h===i&&r(this)),t>h||i>h)for(s=a.length-1;s>=0;s--)o=a[s],e.intersects(o._bounds)&&o._recursively(e,t,i,n,r)},_isSingleParent:function(){return this._childClusters.length>0&&this._childClusters[0]._childCount===this._childCount}}),L.Marker.include({clusterHide:function(){return this.options.opacityWhenUnclustered=this.options.opacity||1,this.setOpacity(0)},clusterShow:function(){var e=this.setOpacity(this.options.opacity||this.options.opacityWhenUnclustered);return delete this.options.opacityWhenUnclustered,e}}),L.DistanceGrid=function(e){this._cellSize=e,this._sqCellSize=e*e,this._grid={},this._objectPoint={}},L.DistanceGrid.prototype={addObject:function(e,t){var i=this._getCoord(t.x),n=this._getCoord(t.y),r=this._grid,s=r[n]=r[n]||{},o=s[i]=s[i]||[],a=L.Util.stamp(e);this._objectPoint[a]=t,o.push(e)},updateObject:function(e,t){this.removeObject(e),this.addObject(e,t)},removeObject:function(e,t){var i,n,r=this._getCoord(t.x),s=this._getCoord(t.y),o=this._grid,a=o[s]=o[s]||{},h=a[r]=a[r]||[];for(delete this._objectPoint[L.Util.stamp(e)],i=0,n=h.length;n>i;i++)if(h[i]===e)return h.splice(i,1),1===n&&delete a[r],!0},eachObject:function(e,t){var i,n,r,s,o,a,h,l=this._grid;for(i in l){o=l[i];for(n in o)for(a=o[n],r=0,s=a.length;s>r;r++)h=e.call(t,a[r]),h&&(r--,s--)}},getNearObject:function(e){var t,i,n,r,s,o,a,h,l=this._getCoord(e.x),u=this._getCoord(e.y),_=this._objectPoint,d=this._sqCellSize,c=null;for(t=u-1;u+1>=t;t++)if(r=this._grid[t])for(i=l-1;l+1>=i;i++)if(s=r[i])for(n=0,o=s.length;o>n;n++)a=s[n],h=this._sqDist(_[L.Util.stamp(a)],e),(d>h||d>=h&&null===c)&&(d=h,c=a);return c},_getCoord:function(e){var t=Math.floor(e/this._cellSize);return isFinite(t)?t:e},_sqDist:function(e,t){var i=t.x-e.x,n=t.y-e.y;return i*i+n*n}},function(){L.QuickHull={getDistant:function(e,t){var i=t[1].lat-t[0].lat,n=t[0].lng-t[1].lng;return n*(e.lat-t[0].lat)+i*(e.lng-t[0].lng)},findMostDistantPointFromBaseLine:function(e,t){var i,n,r,s=0,o=null,a=[];for(i=t.length-1;i>=0;i--)n=t[i],r=this.getDistant(n,e),r>0&&(a.push(n),r>s&&(s=r,o=n));return{maxPoint:o,newPoints:a}},buildConvexHull:function(e,t){var i=[],n=this.findMostDistantPointFromBaseLine(e,t);return n.maxPoint?(i=i.concat(this.buildConvexHull([e[0],n.maxPoint],n.newPoints)),i=i.concat(this.buildConvexHull([n.maxPoint,e[1]],n.newPoints))):[e[0]]},getConvexHull:function(e){var t,i=!1,n=!1,r=!1,s=!1,o=null,a=null,h=null,l=null,u=null,_=null;for(t=e.length-1;t>=0;t--){var d=e[t];(i===!1||d.lat>i)&&(o=d,i=d.lat),(n===!1||d.latr)&&(h=d,r=d.lng),(s===!1||d.lng=0;t--)e=i[t].getLatLng(),n.push(e);return L.QuickHull.getConvexHull(n)}}),L.MarkerCluster.include({_2PI:2*Math.PI,_circleFootSeparation:25,_circleStartAngle:Math.PI/6,_spiralFootSeparation:28,_spiralLengthStart:11,_spiralLengthFactor:5,_circleSpiralSwitchover:9,spiderfy:function(){if(this._group._spiderfied!==this&&!this._group._inZoomAnimation){var e,t=this.getAllChildMarkers(),i=this._group,n=i._map,r=n.latLngToLayerPoint(this._latlng);this._group._unspiderfy(),this._group._spiderfied=this,t.length>=this._circleSpiralSwitchover?e=this._generatePointsSpiral(t.length,r):(r.y+=10,e=this._generatePointsCircle(t.length,r)),this._animationSpiderfy(t,e)}},unspiderfy:function(e){this._group._inZoomAnimation||(this._animationUnspiderfy(e),this._group._spiderfied=null)},_generatePointsCircle:function(e,t){var i,n,r=this._group.options.spiderfyDistanceMultiplier*this._circleFootSeparation*(2+e),s=r/this._2PI,o=this._2PI/e,a=[];for(a.length=e,i=e-1;i>=0;i--)n=this._circleStartAngle+i*o,a[i]=new L.Point(t.x+s*Math.cos(n),t.y+s*Math.sin(n))._round();return a},_generatePointsSpiral:function(e,t){var i,n=this._group.options.spiderfyDistanceMultiplier,r=n*this._spiralLengthStart,s=n*this._spiralFootSeparation,o=n*this._spiralLengthFactor*this._2PI,a=0,h=[];for(h.length=e,i=e-1;i>=0;i--)a+=s/r+5e-4*i,h[i]=new L.Point(t.x+r*Math.cos(a),t.y+r*Math.sin(a))._round(),r+=o/a;return h},_noanimationUnspiderfy:function(){var e,t,i=this._group,n=i._map,r=i._featureGroup,s=this.getAllChildMarkers();for(i._ignoreMove=!0,this.setOpacity(1),t=s.length-1;t>=0;t--)e=s[t],r.removeLayer(e),e._preSpiderfyLatlng&&(e.setLatLng(e._preSpiderfyLatlng),delete e._preSpiderfyLatlng),e.setZIndexOffset&&e.setZIndexOffset(0),e._spiderLeg&&(n.removeLayer(e._spiderLeg),delete e._spiderLeg);i.fire("unspiderfied",{cluster:this,markers:s}),i._ignoreMove=!1,i._spiderfied=null}}),L.MarkerClusterNonAnimated=L.MarkerCluster.extend({_animationSpiderfy:function(e,t){var i,n,r,s,o=this._group,a=o._map,h=o._featureGroup,l=this._group.options.spiderLegPolylineOptions;for(o._ignoreMove=!0,i=0;i=0;n--)h=_.layerPointToLatLng(t[n]),r=e[n],r._preSpiderfyLatlng=r._latlng,r.setLatLng(h),r.clusterShow&&r.clusterShow(),f&&(s=r._spiderLeg,o=s._path,o.style.strokeDashoffset=0,s.setStyle({opacity:g}));this.setOpacity(.3),u._ignoreMove=!1,setTimeout(function(){u._animationEnd(),u.fire("spiderfied",{cluster:l,markers:e})},200)},_animationUnspiderfy:function(e){var t,i,n,r,s,o,a=this,h=this._group,l=h._map,u=h._featureGroup,_=e?l._latLngToNewLayerPoint(this._latlng,e.zoom,e.center):l.latLngToLayerPoint(this._latlng),d=this.getAllChildMarkers(),c=L.Path.SVG;for(h._ignoreMove=!0,h._animationStart(),this.setOpacity(1),i=d.length-1;i>=0;i--)t=d[i],t._preSpiderfyLatlng&&(t.closePopup(),t.setLatLng(t._preSpiderfyLatlng),delete t._preSpiderfyLatlng,o=!0,t._setPos&&(t._setPos(_),o=!1),t.clusterHide&&(t.clusterHide(),o=!1),o&&u.removeLayer(t),c&&(n=t._spiderLeg,r=n._path,s=r.getTotalLength()+.1,r.style.strokeDashoffset=s,n.setStyle({opacity:0})));h._ignoreMove=!1,setTimeout(function(){var e=0;for(i=d.length-1;i>=0;i--)t=d[i],t._spiderLeg&&e++;for(i=d.length-1;i>=0;i--)t=d[i],t._spiderLeg&&(t.clusterShow&&t.clusterShow(),t.setZIndexOffset&&t.setZIndexOffset(0),e>1&&u.removeLayer(t),l.removeLayer(t._spiderLeg),delete t._spiderLeg);h._animationEnd(),h.fire("unspiderfied",{cluster:a,markers:d})},200)}}),L.MarkerClusterGroup.include({_spiderfied:null,unspiderfy:function(){this._unspiderfy.apply(this,arguments)},_spiderfierOnAdd:function(){this._map.on("click",this._unspiderfyWrapper,this),this._map.options.zoomAnimation&&this._map.on("zoomstart",this._unspiderfyZoomStart,this),this._map.on("zoomend",this._noanimationUnspiderfy,this),L.Browser.touch||this._map.getRenderer(this)},_spiderfierOnRemove:function(){this._map.off("click",this._unspiderfyWrapper,this),this._map.off("zoomstart",this._unspiderfyZoomStart,this),this._map.off("zoomanim",this._unspiderfyZoomAnim,this),this._map.off("zoomend",this._noanimationUnspiderfy,this),this._noanimationUnspiderfy()},_unspiderfyZoomStart:function(){this._map&&this._map.on("zoomanim",this._unspiderfyZoomAnim,this)},_unspiderfyZoomAnim:function(e){L.DomUtil.hasClass(this._map._mapPane,"leaflet-touching")||(this._map.off("zoomanim",this._unspiderfyZoomAnim,this),this._unspiderfy(e))},_unspiderfyWrapper:function(){this._unspiderfy() +},_unspiderfy:function(e){this._spiderfied&&this._spiderfied.unspiderfy(e)},_noanimationUnspiderfy:function(){this._spiderfied&&this._spiderfied._noanimationUnspiderfy()},_unspiderfyLayer:function(e){e._spiderLeg&&(this._featureGroup.removeLayer(e),e.clusterShow&&e.clusterShow(),e.setZIndexOffset&&e.setZIndexOffset(0),this._map.removeLayer(e._spiderLeg),delete e._spiderLeg)}}),L.MarkerClusterGroup.include({refreshClusters:function(e){return e?e instanceof L.MarkerClusterGroup?e=e._topClusterLevel.getAllChildMarkers():e instanceof L.LayerGroup?e=e._layers:e instanceof L.MarkerCluster?e=e.getAllChildMarkers():e instanceof L.Marker&&(e=[e]):e=this._topClusterLevel.getAllChildMarkers(),this._flagParentsIconsNeedUpdate(e),this._refreshClustersIcons(),this.options.singleMarkerMode&&this._refreshSingleMarkerModeMarkers(e),this},_flagParentsIconsNeedUpdate:function(e){var t,i;for(t in e)for(i=e[t].__parent;i;)i._iconNeedsUpdate=!0,i=i.__parent},_refreshSingleMarkerModeMarkers:function(e){var t,i;for(t in e)i=e[t],this.hasLayer(i)&&i.setIcon(this._overrideMarkerIcon(i))}}),L.Marker.include({refreshIconOptions:function(e,t){var i=this.options.icon;return L.setOptions(i,e),this.setIcon(i),t&&this.__parent&&this.__parent._group.refreshClusters(this),this}})}(window,document); \ No newline at end of file diff --git a/inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster.layersupport-src.js b/inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster.layersupport-src.js index bad4373e2..e024a0bae 100644 --- a/inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster.layersupport-src.js +++ b/inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster.layersupport-src.js @@ -1,3 +1,19 @@ +/** + * Leaflet.MarkerCluster.LayerSupport 1.0.5+87f3848 + * Sub-plugin for Leaflet.markercluster plugin (MCG in short); brings compatibility with L.Control.Layers and other Leaflet plugins. + * (c) 2015-2017 Boris Seang + * License MIT + */ +(function (root, factory) { + if (typeof define === "function" && define.amd) { + define(["leaflet"], factory); + } else if (typeof module === "object" && module.exports) { + factory(require("leaflet")); + } else { + factory(root.L); + } +}(this, function (L, undefined) { + /** * Extends the L.MarkerClusterGroup class by mainly overriding methods for * addition/removal of layers, so that they can also be directly added/removed @@ -53,13 +69,13 @@ L.MarkerClusterGroup.LayerSupport = L.MarkerClusterGroup.extend({ */ checkOut: function (layers) { var layersArray = this._toArray(layers), - separated = this._separateSingleFromGroupLayers(layersArray, { - groups: [], - singles: [] - }), - groups = separated.groups, - singles = separated.singles, - i, layer; + separated = this._separateSingleFromGroupLayers(layersArray, { + groups: [], + singles: [] + }), + groups = separated.groups, + singles = separated.singles, + i, layer; // Un-stamp single layers. for (i = 0; i < singles.length; i++) { @@ -91,9 +107,9 @@ L.MarkerClusterGroup.LayerSupport = L.MarkerClusterGroup.extend({ */ addLayers: function (layers) { var layersArray = this._toArray(layers), - separated = this._checkInGetSeparated(layersArray), - groups = separated.groups, - i, group, id; + separated = this._checkInGetSeparated(layersArray), + groups = separated.groups, + i, group, id; // Batch add all single layers. this._originalAddLayers(separated.singles); @@ -125,14 +141,14 @@ L.MarkerClusterGroup.LayerSupport = L.MarkerClusterGroup.extend({ */ removeLayers: function (layers) { var layersArray = this._toArray(layers), - separated = this._separateSingleFromGroupLayers(layersArray, { - groups: [], - singles: [] - }), - groups = separated.groups, - singles = separated.singles, - i = 0, - group, id; + separated = this._separateSingleFromGroupLayers(layersArray, { + groups: [], + singles: [] + }), + groups = separated.groups, + singles = separated.singles, + i = 0, + group, id; // Batch remove single layers from MCG. this._originalRemoveLayers(singles); @@ -172,7 +188,7 @@ L.MarkerClusterGroup.LayerSupport = L.MarkerClusterGroup.extend({ // (if it was never added to map before). Therefore we need to // remove all checked in layers from map! var toBeReAdded = this._removePreAddedLayers(map), - id, group, i; + id, group, i; // Normal MCG onAdd. this._originalOnAdd.call(this, map); @@ -209,7 +225,7 @@ L.MarkerClusterGroup.LayerSupport = L.MarkerClusterGroup.extend({ _bufferSingleAddRemove: function (layer, operationType) { var duration = this.options.singleAddRemoveBufferDuration, - fn; + fn; if (duration > 0) { this._singleAddRemoveBuffer.push({ @@ -230,10 +246,10 @@ L.MarkerClusterGroup.LayerSupport = L.MarkerClusterGroup.extend({ // For now, simply cut the processes at each operation change // (addLayers, removeLayers). var singleAddRemoveBuffer = this._singleAddRemoveBuffer, - i = 0, - layersBuffer = [], - currentOperation, - currentOperationType; + i = 0, + layersBuffer = [], + currentOperation, + currentOperationType; for (; i < singleAddRemoveBuffer.length; i++) { currentOperation = singleAddRemoveBuffer[i]; @@ -244,6 +260,7 @@ L.MarkerClusterGroup.LayerSupport = L.MarkerClusterGroup.extend({ layersBuffer.push(currentOperation.layer); } else { this[currentOperationType](layersBuffer); + currentOperationType = currentOperation.type; layersBuffer = [currentOperation.layer]; } } @@ -255,12 +272,12 @@ L.MarkerClusterGroup.LayerSupport = L.MarkerClusterGroup.extend({ _checkInGetSeparated: function (layersArray) { var separated = this._separateSingleFromGroupLayers(layersArray, { - groups: [], - singles: [] - }), - groups = separated.groups, - singles = separated.singles, - i, layer; + groups: [], + singles: [] + }), + groups = separated.groups, + singles = separated.singles, + i, layer; // Recruit Layer Groups. // If they do not already belong to this group, they will be @@ -286,9 +303,9 @@ L.MarkerClusterGroup.LayerSupport = L.MarkerClusterGroup.extend({ _separateSingleFromGroupLayers: function (inputLayers, output) { var groups = output.groups, - singles = output.singles, - isArray = L.Util.isArray, - layer; + singles = output.singles, + isArray = L.Util.isArray, + layer; for (var i = 0; i < inputLayers.length; i++) { layer = inputLayers[i]; @@ -385,8 +402,8 @@ L.MarkerClusterGroup.LayerSupport = L.MarkerClusterGroup.extend({ // In case checked in layers have been added to map whereas map is not redirected. _removePreAddedLayers: function (map) { var layers = this._layers, - toBeReAdded = [], - layer; + toBeReAdded = [], + layer; for (var id in layers) { layer = layers[id]; @@ -503,6 +520,16 @@ var _proxyLayerGroup = { delete this._layers[id]; return this; + }, + + // Make sure it uses addLayers when added to map. + onAdd: function () { + this._proxyMcgLayerSupportGroup.addLayers(this.getLayers()); + }, + + // Make sure it uses removeLayers when removed from map. + onRemove: function () { + this._proxyMcgLayerSupportGroup.removeLayers(this.getLayers()); } }; @@ -539,3 +566,9 @@ var _layerSwitchMap = { L.markerClusterGroup.layerSupport = function (options) { return new L.MarkerClusterGroup.LayerSupport(options); }; + + + +})); + +//# sourceMappingURL=leaflet.markercluster.layersupport-src.js.map \ No newline at end of file diff --git a/inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster.layersupport-src.js.map b/inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster.layersupport-src.js.map new file mode 100644 index 000000000..312e3f58d --- /dev/null +++ b/inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster.layersupport-src.js.map @@ -0,0 +1 @@ +{"version":3,"file":"leaflet.markercluster.layersupport-src.js","sources":["src/layersupport.js"],"sourcesContent":["/**\n * Extends the L.MarkerClusterGroup class by mainly overriding methods for\n * addition/removal of layers, so that they can also be directly added/removed\n * from the map later on while still clustering in this group.\n * @type {L.MarkerClusterGroup}\n */\nL.MarkerClusterGroup.LayerSupport = L.MarkerClusterGroup.extend({\n\n\toptions: {\n\t\t// Buffer single addLayer and removeLayer requests for efficiency.\n\t\tsingleAddRemoveBufferDuration: 100 // in ms.\n\t},\n\n\tinitialize: function (options) {\n\t\tL.MarkerClusterGroup.prototype.initialize.call(this, options);\n\n\t\t// Replace the MCG internal featureGroup's so that they directly\n\t\t// access the map add/removal methods, bypassing the switch agent.\n\t\tthis._featureGroup = new _ByPassingFeatureGroup();\n\t\tthis._featureGroup.addEventParent(this);\n\n\t\tthis._nonPointGroup = new _ByPassingFeatureGroup();\n\t\tthis._nonPointGroup.addEventParent(this);\n\n\t\t// Keep track of what should be \"represented\" on map (can be clustered).\n\t\tthis._layers = {};\n\t\tthis._proxyLayerGroups = {};\n\t\tthis._proxyLayerGroupsNeedRemoving = {};\n\n\t\t// Buffer single addLayer and removeLayer requests.\n\t\tthis._singleAddRemoveBuffer = [];\n\t},\n\n\t/**\n\t * Stamps the passed layers as being part of this group, but without adding\n\t * them to the map right now.\n\t * @param layers L.Layer|Array(L.Layer) layer(s) to be stamped.\n\t * @returns {L.MarkerClusterGroup.LayerSupport} this.\n\t */\n\tcheckIn: function (layers) {\n\t\tvar layersArray = this._toArray(layers);\n\n\t\tthis._checkInGetSeparated(layersArray);\n\n\t\treturn this;\n\t},\n\n\t/**\n\t * Un-stamps the passed layers from being part of this group. It has to\n\t * remove them from map (if they are) since they will no longer cluster.\n\t * @param layers L.Layer|Array(L.Layer) layer(s) to be un-stamped.\n\t * @returns {L.MarkerClusterGroup.LayerSupport} this.\n\t */\n\tcheckOut: function (layers) {\n\t\tvar layersArray = this._toArray(layers),\n\t\t separated = this._separateSingleFromGroupLayers(layersArray, {\n\t\t groups: [],\n\t\t singles: []\n\t\t }),\n\t\t groups = separated.groups,\n\t\t singles = separated.singles,\n\t\t i, layer;\n\n\t\t// Un-stamp single layers.\n\t\tfor (i = 0; i < singles.length; i++) {\n\t\t\tlayer = singles[i];\n\t\t\tdelete this._layers[L.stamp(layer)];\n\t\t\tdelete layer._mcgLayerSupportGroup;\n\t\t}\n\n\t\t// Batch remove single layers from MCG.\n\t\t// Note: as for standard MCG, if single layers have been added to\n\t\t// another MCG in the meantime, their __parent will have changed,\n\t\t// so weird things would happen.\n\t\tthis._originalRemoveLayers(singles);\n\n\t\t// Dismiss Layer Groups.\n\t\tfor (i = 0; i < groups.length; i++) {\n\t\t\tlayer = groups[i];\n\t\t\tthis._dismissProxyLayerGroup(layer);\n\t\t}\n\n\t\treturn this;\n\t},\n\n\t/**\n\t * Checks in and adds an array of layers to this group.\n\t * Layer Groups are also added to the map to fire their event.\n\t * @param layers (L.Layer|L.Layer[]) single and/or group layers to be added.\n\t * @returns {L.MarkerClusterGroup.LayerSupport} this.\n\t */\n\taddLayers: function (layers) {\n\t\tvar layersArray = this._toArray(layers),\n\t\t separated = this._checkInGetSeparated(layersArray),\n\t\t groups = separated.groups,\n\t\t i, group, id;\n\n\t\t// Batch add all single layers.\n\t\tthis._originalAddLayers(separated.singles);\n\n\t\t// Add Layer Groups to the map so that they are registered there and\n\t\t// the map fires 'layeradd' events for them as well.\n\t\tfor (i = 0; i < groups.length; i++) {\n\t\t\tgroup = groups[i];\n\t\t\tid = L.stamp(group);\n\t\t\tthis._proxyLayerGroups[id] = group;\n\t\t\tdelete this._proxyLayerGroupsNeedRemoving[id];\n\t\t\tif (this._map) {\n\t\t\t\tthis._map._originalAddLayer(group);\n\t\t\t}\n\t\t}\n\t},\n\taddLayer: function (layer) {\n\t\tthis._bufferSingleAddRemove(layer, \"addLayers\");\n\t\treturn this;\n\t},\n\t_originalAddLayer: L.MarkerClusterGroup.prototype.addLayer,\n\t_originalAddLayers: L.MarkerClusterGroup.prototype.addLayers,\n\n\t/**\n\t * Removes layers from this group but without check out.\n\t * Layer Groups are also removed from the map to fire their event.\n\t * @param layers (L.Layer|L.Layer[]) single and/or group layers to be removed.\n\t * @returns {L.MarkerClusterGroup.LayerSupport} this.\n\t */\n\tremoveLayers: function (layers) {\n\t\tvar layersArray = this._toArray(layers),\n\t\t separated = this._separateSingleFromGroupLayers(layersArray, {\n\t\t groups: [],\n\t\t singles: []\n\t\t }),\n\t\t groups = separated.groups,\n\t\t singles = separated.singles,\n\t\t i = 0,\n\t\t group, id;\n\n\t\t// Batch remove single layers from MCG.\n\t\tthis._originalRemoveLayers(singles);\n\n\t\t// Remove Layer Groups from the map so that they are un-registered\n\t\t// there and the map fires 'layerremove' events for them as well.\n\t\tfor (; i < groups.length; i++) {\n\t\t\tgroup = groups[i];\n\t\t\tid = L.stamp(group);\n\t\t\tdelete this._proxyLayerGroups[id];\n\t\t\tif (this._map) {\n\t\t\t\tthis._map._originalRemoveLayer(group);\n\t\t\t} else {\n\t\t\t\tthis._proxyLayerGroupsNeedRemoving[id] = group;\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t},\n\tremoveLayer: function (layer) {\n\t\tthis._bufferSingleAddRemove(layer, \"removeLayers\");\n\t\treturn this;\n\t},\n\t_originalRemoveLayer: L.MarkerClusterGroup.prototype.removeLayer,\n\t_originalRemoveLayers: L.MarkerClusterGroup.prototype.removeLayers,\n\n\tonAdd: function (map) {\n\t\t// Replace the map addLayer and removeLayer methods to place the\n\t\t// switch agent that redirects layers when required.\n\t\tmap._originalAddLayer = map._originalAddLayer || map.addLayer;\n\t\tmap._originalRemoveLayer = map._originalRemoveLayer || map.removeLayer;\n\t\tL.extend(map, _layerSwitchMap);\n\n\t\t// As this plugin allows the Application to add layers on map, some\n\t\t// checked in layers might have been added already, whereas LayerSupport\n\t\t// did not have a chance to inject the switch agent in to the map\n\t\t// (if it was never added to map before). Therefore we need to\n\t\t// remove all checked in layers from map!\n\t\tvar toBeReAdded = this._removePreAddedLayers(map),\n\t\t id, group, i;\n\n\t\t// Normal MCG onAdd.\n\t\tthis._originalOnAdd.call(this, map);\n\n\t\t// If layer Groups are added/removed from this group while it is not\n\t\t// on map, Control.Layers gets out of sync until this is added back.\n\n\t\t// Restore proxy Layer Groups that may have been added to this\n\t\t// group while it was off map.\n\t\tfor (id in this._proxyLayerGroups) {\n\t\t\tgroup = this._proxyLayerGroups[id];\n\t\t\tmap._originalAddLayer(group);\n\t\t}\n\n\t\t// Remove proxy Layer Groups that may have been removed from this\n\t\t// group while it was off map.\n\t\tfor (id in this._proxyLayerGroupsNeedRemoving) {\n\t\t\tgroup = this._proxyLayerGroupsNeedRemoving[id];\n\t\t\tmap._originalRemoveLayer(group);\n\t\t\tdelete this._proxyLayerGroupsNeedRemoving[id];\n\t\t}\n\n\t\t// Restore Layers.\n\t\tfor (i = 0; i < toBeReAdded.length; i++) {\n\t\t\tmap.addLayer(toBeReAdded[i]);\n\t\t}\n\t},\n\t_originalOnAdd: L.MarkerClusterGroup.prototype.onAdd,\n\n\t// Do not restore the original map methods when removing the group from it.\n\t// Leaving them as-is does not harm, whereas restoring the original ones\n\t// may kill the functionality of potential other LayerSupport groups on\n\t// the same map. Therefore we do not need to override onRemove.\n\n\t_bufferSingleAddRemove: function (layer, operationType) {\n\t\tvar duration = this.options.singleAddRemoveBufferDuration,\n\t\t fn;\n\n\t\tif (duration > 0) {\n\t\t\tthis._singleAddRemoveBuffer.push({\n\t\t\t\ttype: operationType,\n\t\t\t\tlayer: layer\n\t\t\t});\n\n\t\t\tif (!this._singleAddRemoveBufferTimeout) {\n\t\t\t\tfn = L.bind(this._processSingleAddRemoveBuffer, this);\n\n\t\t\t\tthis._singleAddRemoveBufferTimeout = setTimeout(fn, duration);\n\t\t\t}\n\t\t} else { // If duration <= 0, process synchronously.\n\t\t\tthis[operationType](layer);\n\t\t}\n\t},\n\t_processSingleAddRemoveBuffer: function () {\n\t\t// For now, simply cut the processes at each operation change\n\t\t// (addLayers, removeLayers).\n\t\tvar singleAddRemoveBuffer = this._singleAddRemoveBuffer,\n\t\t i = 0,\n\t\t layersBuffer = [],\n\t\t currentOperation,\n\t\t currentOperationType;\n\n\t\tfor (; i < singleAddRemoveBuffer.length; i++) {\n\t\t\tcurrentOperation = singleAddRemoveBuffer[i];\n\t\t\tif (!currentOperationType) {\n\t\t\t\tcurrentOperationType = currentOperation.type;\n\t\t\t}\n\t\t\tif (currentOperation.type === currentOperationType) {\n\t\t\t\tlayersBuffer.push(currentOperation.layer);\n\t\t\t} else {\n\t\t\t\tthis[currentOperationType](layersBuffer);\n\t\t\t\tcurrentOperationType = currentOperation.type;\n\t\t\t\tlayersBuffer = [currentOperation.layer];\n\t\t\t}\n\t\t}\n\t\tthis[currentOperationType](layersBuffer);\n\t\tsingleAddRemoveBuffer.length = 0;\n\t\tclearTimeout(this._singleAddRemoveBufferTimeout);\n\t\tthis._singleAddRemoveBufferTimeout = null;\n\t},\n\n\t_checkInGetSeparated: function (layersArray) {\n\t\tvar separated = this._separateSingleFromGroupLayers(layersArray, {\n\t\t groups: [],\n\t\t singles: []\n\t\t }),\n\t\t groups = separated.groups,\n\t\t singles = separated.singles,\n\t\t i, layer;\n\n\t\t// Recruit Layer Groups.\n\t\t// If they do not already belong to this group, they will be\n\t\t// removed from map (together will all child layers).\n\t\tfor (i = 0; i < groups.length; i++) {\n\t\t\tlayer = groups[i];\n\t\t\tthis._recruitLayerGroupAsProxy(layer);\n\t\t}\n\n\t\t// Stamp single layers.\n\t\tfor (i = 0; i < singles.length; i++) {\n\t\t\tlayer = singles[i];\n\n\t\t\t// Remove from previous group first.\n\t\t\tthis._removeFromOtherGroupsOrMap(layer);\n\n\t\t\tthis._layers[L.stamp(layer)] = layer;\n\t\t\tlayer._mcgLayerSupportGroup = this;\n\t\t}\n\n\t\treturn separated;\n\t},\n\n\t_separateSingleFromGroupLayers: function (inputLayers, output) {\n\t\tvar groups = output.groups,\n\t\t singles = output.singles,\n\t\t isArray = L.Util.isArray,\n\t\t layer;\n\n\t\tfor (var i = 0; i < inputLayers.length; i++) {\n\t\t\tlayer = inputLayers[i];\n\n\t\t\tif (layer instanceof L.LayerGroup) {\n\t\t\t\tgroups.push(layer);\n\t\t\t\tthis._separateSingleFromGroupLayers(layer.getLayers(), output);\n\t\t\t\tcontinue;\n\t\t\t} else if (isArray(layer)) {\n\t\t\t\tthis._separateSingleFromGroupLayers(layer, output);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tsingles.push(layer);\n\t\t}\n\n\t\treturn output;\n\t},\n\n\t// Recruit the LayerGroup as a proxy, so that any layer that is added\n\t// to / removed from that group later on is also added to / removed from\n\t// this group.\n\t// Check in and addition of already contained markers must be taken care\n\t// of externally.\n\t_recruitLayerGroupAsProxy: function (layerGroup) {\n\t\tvar otherMcgLayerSupportGroup = layerGroup._proxyMcgLayerSupportGroup;\n\n\t\t// If it is not yet in this group, remove it from previous group\n\t\t// or from map.\n\t\tif (otherMcgLayerSupportGroup) {\n\t\t\tif (otherMcgLayerSupportGroup === this) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Remove from previous Layer Support group first.\n\t\t\t// It will also be removed from map with child layers.\n\t\t\totherMcgLayerSupportGroup.checkOut(layerGroup);\n\t\t} else {\n\t\t\tthis._removeFromOwnMap(layerGroup);\n\t\t}\n\n\t\tlayerGroup._proxyMcgLayerSupportGroup = this;\n\t\tlayerGroup._originalAddLayer =\n\t\t\tlayerGroup._originalAddLayer || layerGroup.addLayer;\n\t\tlayerGroup._originalRemoveLayer =\n\t\t\tlayerGroup._originalRemoveLayer || layerGroup.removeLayer;\n\t\tL.extend(layerGroup, _proxyLayerGroup);\n\t},\n\n\t// Restore the normal LayerGroup behaviour.\n\t// Removal and check out of contained markers must be taken care of externally.\n\t_dismissProxyLayerGroup: function (layerGroup) {\n\t\tif (layerGroup._proxyMcgLayerSupportGroup === undefined ||\n\t\t\tlayerGroup._proxyMcgLayerSupportGroup !== this) {\n\n\t\t\treturn;\n\t\t}\n\n\t\tdelete layerGroup._proxyMcgLayerSupportGroup;\n\t\tlayerGroup.addLayer = layerGroup._originalAddLayer;\n\t\tlayerGroup.removeLayer = layerGroup._originalRemoveLayer;\n\n\t\tvar id = L.stamp(layerGroup);\n\t\tdelete this._proxyLayerGroups[id];\n\t\tdelete this._proxyLayerGroupsNeedRemoving[id];\n\n\t\tthis._removeFromOwnMap(layerGroup);\n\t},\n\n\t_removeFromOtherGroupsOrMap: function (layer) {\n\t\tvar otherMcgLayerSupportGroup = layer._mcgLayerSupportGroup;\n\n\t\tif (otherMcgLayerSupportGroup) { // It is a Layer Support group.\n\t\t\tif (otherMcgLayerSupportGroup === this) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\totherMcgLayerSupportGroup.checkOut(layer);\n\n\t\t} else if (layer.__parent) { // It is in a normal MCG.\n\t\t\tlayer.__parent._group.removeLayer(layer);\n\n\t\t} else { // It could still be on a map.\n\t\t\tthis._removeFromOwnMap(layer);\n\t\t}\n\t},\n\n\t// Remove layers that are being checked in, because they can now cluster.\n\t_removeFromOwnMap: function (layer) {\n\t\tif (layer._map) {\n\t\t\t// This correctly fires layerremove event for Layer Groups as well.\n\t\t\tlayer._map.removeLayer(layer);\n\t\t}\n\t},\n\n\t// In case checked in layers have been added to map whereas map is not redirected.\n\t_removePreAddedLayers: function (map) {\n\t\tvar layers = this._layers,\n\t\t toBeReAdded = [],\n\t\t layer;\n\n\t\tfor (var id in layers) {\n\t\t\tlayer = layers[id];\n\t\t\tif (layer._map) {\n\t\t\t\ttoBeReAdded.push(layer);\n\t\t\t\tmap._originalRemoveLayer(layer);\n\t\t\t}\n\t\t}\n\n\t\treturn toBeReAdded;\n\t},\n\n\t_toArray: function (item) {\n\t\treturn L.Util.isArray(item) ? item : [item];\n\t}\n\n});\n\n/**\n * Extends the FeatureGroup by overriding add/removal methods that directly\n * access the map original methods, bypassing the switch agent.\n * Used internally in Layer Support for _featureGroup and _nonPointGroup only.\n * @type {L.FeatureGroup}\n * @private\n */\nvar _ByPassingFeatureGroup = L.FeatureGroup.extend({\n\n\t// Re-implement just to change the map method.\n\taddLayer: function (layer) {\n\t\tif (this.hasLayer(layer)) {\n\t\t\treturn this;\n\t\t}\n\n\t\tlayer.addEventParent(this);\n\n\t\tvar id = L.stamp(layer);\n\n\t\tthis._layers[id] = layer;\n\n\t\tif (this._map) {\n\t\t\t// Use the original map addLayer.\n\t\t\tthis._map._originalAddLayer(layer);\n\t\t}\n\n\t\treturn this.fire('layeradd', {layer: layer});\n\t},\n\n\t// Re-implement just to change the map method.\n\tremoveLayer: function (layer) {\n\t\tif (!this.hasLayer(layer)) {\n\t\t\treturn this;\n\t\t}\n\t\tif (layer in this._layers) {\n\t\t\tlayer = this._layers[layer];\n\t\t}\n\n\t\tlayer.removeEventParent(this);\n\n\t\tvar id = L.stamp(layer);\n\n\t\tif (this._map && this._layers[id]) {\n\t\t\t// Use the original map removeLayer.\n\t\t\tthis._map._originalRemoveLayer(this._layers[id]);\n\t\t}\n\n\t\tdelete this._layers[id];\n\n\t\treturn this.fire('layerremove', {layer: layer});\n\t},\n\n\tonAdd: function (map) {\n\t\tthis._map = map;\n\t\t// Use the original map addLayer.\n\t\tthis.eachLayer(map._originalAddLayer, map);\n\t},\n\n\tonRemove: function (map) {\n\t\t// Use the original map removeLayer.\n\t\tthis.eachLayer(map._originalRemoveLayer, map);\n\t\tthis._map = null;\n\t}\n\n});\n\n/**\n * Toolbox to equip LayerGroups recruited as proxy.\n * @type {{addLayer: Function, removeLayer: Function}}\n * @private\n */\nvar _proxyLayerGroup = {\n\n\t// Re-implement to redirect addLayer to Layer Support group instead of map.\n\taddLayer: function (layer) {\n\t\tvar id = this.getLayerId(layer);\n\n\t\tthis._layers[id] = layer;\n\n\t\tif (this._map) {\n\t\t\tthis._proxyMcgLayerSupportGroup.addLayer(layer);\n\t\t} else {\n\t\t\tthis._proxyMcgLayerSupportGroup.checkIn(layer);\n\t\t}\n\n\t\treturn this;\n\t},\n\n\t// Re-implement to redirect removeLayer to Layer Support group instead of map.\n\tremoveLayer: function (layer) {\n\n\t\tvar id = layer in this._layers ? layer : this.getLayerId(layer);\n\n\t\tthis._proxyMcgLayerSupportGroup.removeLayer(layer);\n\n\t\tdelete this._layers[id];\n\n\t\treturn this;\n\t},\n\n\t// Make sure it uses addLayers when added to map.\n\tonAdd: function () {\n\t\tthis._proxyMcgLayerSupportGroup.addLayers(this.getLayers());\n\t},\n\n\t// Make sure it uses removeLayers when removed from map.\n\tonRemove: function () {\n\t\tthis._proxyMcgLayerSupportGroup.removeLayers(this.getLayers());\n\t}\n\n};\n\n/**\n * Toolbox to equip the Map with a switch agent that redirects layers\n * addition/removal to their Layer Support group when defined.\n * @type {{addLayer: Function, removeLayer: Function}}\n * @private\n */\nvar _layerSwitchMap = {\n\n\taddLayer: function (layer) {\n\t\tif (layer._mcgLayerSupportGroup) {\n\t\t\t// Use the original MCG addLayer.\n\t\t\treturn layer._mcgLayerSupportGroup._originalAddLayer(layer);\n\t\t}\n\n\t\treturn this._originalAddLayer(layer);\n\t},\n\n\tremoveLayer: function (layer) {\n\t\tif (layer._mcgLayerSupportGroup) {\n\t\t\t// Use the original MCG removeLayer.\n\t\t\treturn layer._mcgLayerSupportGroup._originalRemoveLayer(layer);\n\t\t}\n\n\t\treturn this._originalRemoveLayer(layer);\n\t}\n\n};\n\n// Supply with a factory for consistency with Leaflet.\nL.markerClusterGroup.layerSupport = function (options) {\n\treturn new L.MarkerClusterGroup.LayerSupport(options);\n};\n\n\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;,;;"} \ No newline at end of file diff --git a/inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster.layersupport.js b/inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster.layersupport.js new file mode 100644 index 000000000..dd41e8caa --- /dev/null +++ b/inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster.layersupport.js @@ -0,0 +1,6 @@ +/*! + Leaflet.MarkerCluster.LayerSupport 1.0.5+87f3848 + (c) 2015-2017 Boris Seang + License MIT + */ +!function(e,r){"function"==typeof define&&define.amd?define(["leaflet"],r):r("object"==typeof module&&module.exports?require("leaflet"):e.L)}(this,function(e,r){e.MarkerClusterGroup.LayerSupport=e.MarkerClusterGroup.extend({options:{singleAddRemoveBufferDuration:100},initialize:function(r){e.MarkerClusterGroup.prototype.initialize.call(this,r),this._featureGroup=new o,this._featureGroup.addEventParent(this),this._nonPointGroup=new o,this._nonPointGroup.addEventParent(this),this._layers={},this._proxyLayerGroups={},this._proxyLayerGroupsNeedRemoving={},this._singleAddRemoveBuffer=[]},checkIn:function(e){var r=this._toArray(e);return this._checkInGetSeparated(r),this},checkOut:function(r){var o,t,i=this._toArray(r),a=this._separateSingleFromGroupLayers(i,{groups:[],singles:[]}),s=a.groups,n=a.singles;for(o=0;o0?(this._singleAddRemoveBuffer.push({type:o,layer:r}),this._singleAddRemoveBufferTimeout||(t=e.bind(this._processSingleAddRemoveBuffer,this),this._singleAddRemoveBufferTimeout=setTimeout(t,i))):this[o](r)},_processSingleAddRemoveBuffer:function(){for(var e,r,o=this._singleAddRemoveBuffer,t=0,i=[];t= 0) { if (layersForKey.length === 1) { delete ctGroup[layerInfo.ctKey]; diff --git a/javascript/src/methods.js b/javascript/src/methods.js index b9c4d408e..ec4a27dc7 100644 --- a/javascript/src/methods.js +++ b/javascript/src/methods.js @@ -44,12 +44,23 @@ methods.setView = function(center, zoom, options) { this.setView(center, zoom, options); }; -methods.fitBounds = function(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) { this.setMaxBounds([ [lat1, lng1], [lat2, lng2] @@ -177,6 +188,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(this); } } @@ -776,13 +788,13 @@ methods.addLegend = function(options) { height: totalHeight + vMargin*2 + "px" }); - if (options.na_color) { + if (options.na_color && ($.inArray(options.na_label, labels)<0) ) { $(div).append("
" + options.na_label + "
"); } } else { - if (options.na_color) { + if (options.na_color && ($.inArray(options.na_label, labels)<0) ) { colors.push(options.na_color); labels.push(options.na_label); } diff --git a/man/addGraticule.Rd b/man/addGraticule.Rd index be74c8de9..f73ddf9e0 100644 --- a/man/addGraticule.Rd +++ b/man/addGraticule.Rd @@ -16,7 +16,7 @@ addGraticule(map, interval = 20, sphere = FALSE, style = list(color = \item{sphere}{boolean. Default FALSE} -\item{style}{path options for the generated lines. See \url{http://leafletjs.com/reference.html#path-options}} +\item{style}{path options for the generated lines. See \url{http://leafletjs.com/reference-1.2.0.html#path-option}} \item{layerId}{the layer id} diff --git a/man/addLayersControl.Rd b/man/addLayersControl.Rd index 4c33baf60..9b8885183 100644 --- a/man/addLayersControl.Rd +++ b/man/addLayersControl.Rd @@ -41,7 +41,7 @@ the z-order of its various groups as overlays are switched on and off.} } \description{ 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. } diff --git a/man/addMeasure.Rd b/man/addMeasure.Rd index ae3108928..c388c819e 100644 --- a/man/addMeasure.Rd +++ b/man/addMeasure.Rd @@ -15,7 +15,7 @@ addMeasure(map, position = "topright", primaryLengthUnit = "feet", \arguments{ \item{map}{a map widget object} -\item{position}{standard \href{http://leafletjs.com/reference.html#control-positions}{Leaflet control position options}.} +\item{position}{standard \href{http://leafletjs.com/reference-1.2.0.html#control-positions}{Leaflet control position options}.} \item{primaryLengthUnit, secondaryLengthUnit}{units used to display length results. secondaryLengthUnit is optional. @@ -35,7 +35,7 @@ Value should be a color represented as a hexadecimal string.} \item{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}.} \item{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 diff --git a/man/addMiniMap.Rd b/man/addMiniMap.Rd index 8318e1621..d24fdfa12 100644 --- a/man/addMiniMap.Rd +++ b/man/addMiniMap.Rd @@ -58,11 +58,11 @@ Especially useful when 'zoomLevelFixed' is set.} \item{minimized}{Sets whether the minimap should start in a minimized position.} \item{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.)} \item{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.)} \item{strings}{Overrides the default strings allowing for translation.} diff --git a/man/addProviderTiles.Rd b/man/addProviderTiles.Rd index eef263de0..313ebe00a 100644 --- a/man/addProviderTiles.Rd +++ b/man/addProviderTiles.Rd @@ -9,8 +9,7 @@ addProviderTiles(map, provider, layerId = NULL, group = NULL, options = providerTileOptions()) providerTileOptions(errorTileUrl = "", noWrap = FALSE, opacity = NULL, - zIndex = NULL, unloadInvisibleTiles = NULL, updateWhenIdle = NULL, - detectRetina = FALSE, reuseTiles = FALSE, ...) + zIndex = NULL, updateWhenIdle = NULL, detectRetina = FALSE, ...) } \arguments{ \item{map}{the map to add the tile layer to} @@ -28,8 +27,8 @@ identifier-style names.} \item{options}{tile options} -\item{errorTileUrl, noWrap, opacity, zIndex, unloadInvisibleTiles, updateWhenIdle, detectRetina, reuseTiles}{the tile layer options; see -\url{http://leafletjs.com/reference.html#tilelayer}} +\item{errorTileUrl, noWrap, opacity, zIndex, updateWhenIdle, detectRetina}{the tile layer options; see +\url{http://leafletjs.com/reference-1.2.0.html#tilelayer}} \item{...}{named parameters to add to the options} } diff --git a/man/addRasterImage.Rd b/man/addRasterImage.Rd index d51a95d3f..851afdecc 100644 --- a/man/addRasterImage.Rd +++ b/man/addRasterImage.Rd @@ -7,9 +7,9 @@ \usage{ addRasterImage(map, x, colors = "Spectral", opacity = 1, attribution = NULL, layerId = NULL, group = NULL, project = TRUE, - maxBytes = 4 * 1024 * 1024) + method = c("bilinear", "ngb"), maxBytes = 4 * 1024 * 1024) -projectRasterForLeaflet(x) +projectRasterForLeaflet(x, method) } \arguments{ \item{map}{a map widget object} @@ -35,6 +35,11 @@ the caller's responsibility to ensure that \code{x} is already projected, and that \code{extent(x)} is expressed in WGS84 latitude/longitude coordinates} +\item{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.} + \item{maxBytes}{the maximum number of bytes to allow for the projected image (before base64 encoding); defaults to 4MB.} } diff --git a/man/addScaleBar.Rd b/man/addScaleBar.Rd index ecb4cf915..04ecbbedd 100644 --- a/man/addScaleBar.Rd +++ b/man/addScaleBar.Rd @@ -37,7 +37,7 @@ on \code{moveend}.} } \description{ 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. } \examples{ diff --git a/man/leaflet.Rd b/man/leaflet.Rd index e27097d3e..5a1f4e1e0 100644 --- a/man/leaflet.Rd +++ b/man/leaflet.Rd @@ -7,7 +7,7 @@ \title{Create a Leaflet map widget} \usage{ leaflet(data = NULL, width = NULL, height = NULL, padding = 0, - options = leafletOptions()) + options = leafletOptions(), elementId = NULL) leafletOptions(minZoom = NULL, maxZoom = NULL, crs = leafletCRS(), worldCopyJump = NULL, ...) @@ -33,6 +33,9 @@ spatial data frames from the \pkg{sf} package.} \item{options}{the map options} +\item{elementId}{Use an explicit element ID for the widget +(rather than an automatically generated one).} + \item{minZoom}{Minimum zoom level of the map. Overrides any minZoom set on map layers.} \item{maxZoom}{Maximum zoom level of the map. This overrides any maxZoom set on map layers.} @@ -44,13 +47,13 @@ spatial data frames from the \pkg{sf} package.} \item{...}{other options.} \item{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} \item{code}{CRS identifier} \item{proj4def}{Proj4 string} -\item{projectedBounds}{Only when crsClass = 'L.Proj.CRS.TMS'} +\item{projectedBounds}{DEPRECATED! Use the bounds argument.} \item{origin}{Origin in projected coordinates, if set overrides transformation option.} @@ -66,8 +69,7 @@ for zoom levels; specify either scales or resolutions, not both} Proj4Leaflet will use this in the getSize method, otherwise defaulting to Leaflet's default CRS size} -\item{tileSize}{Tile size, in pixels, to use in this CRS (Default 256) -Only needed when crsClass = 'L.Proj.CRS.TMS'} +\item{tileSize}{DEPRECATED! Specify the tilesize in the \code{\link{tileOptions}()} argument.} } \value{ A HTML widget object, on which we can add graphics layers using @@ -261,5 +263,5 @@ m \%>\% addCircleMarkers(~lng, ~lat, radius = ~size, \seealso{ \code{\link{leafletCRS}} for creating a custom CRS. -\url{http://leafletjs.com/reference.html#map-options} for details. +\url{http://leafletjs.com/reference-1.2.0.html#map-option} for details. } diff --git a/man/map-layers.Rd b/man/map-layers.Rd index fb991f6ba..492d37d9d 100644 --- a/man/map-layers.Rd +++ b/man/map-layers.Rd @@ -244,7 +244,7 @@ Options to highlight shapes (polylines/polygons/circles/rectangles) \references{ The Leaflet API documentation: - \url{http://leafletjs.com/reference.html} + \url{http://leafletjs.com/reference-1.2.0.html} } \seealso{ \code{\link{tileOptions}}, \code{\link{WMSTileOptions}}, diff --git a/man/map-methods.Rd b/man/map-methods.Rd index 5c05c846b..a6d8e837a 100644 --- a/man/map-methods.Rd +++ b/man/map-methods.Rd @@ -2,14 +2,20 @@ % Please edit documentation in R/methods.R \name{setView} \alias{setView} +\alias{flyTo} \alias{fitBounds} +\alias{flyToBounds} \alias{setMaxBounds} \alias{clearBounds} \title{Methods to manipulate the map widget} \usage{ setView(map, lng, lat, zoom, options = list()) -fitBounds(map, lng1, lat1, lng2, lat2) +flyTo(map, lng, lat, zoom, options = list()) + +fitBounds(map, lng1, lat1, lng2, lat2, options = list()) + +flyToBounds(map, lng1, lat1, lng2, lat2, options = list()) setMaxBounds(map, lng1, lat1, lng2, lat2) @@ -25,7 +31,7 @@ clearBounds(map) \item{zoom}{the zoom level} \item{options}{a list of zoom/pan options (see -\url{http://leafletjs.com/reference.html#map-zoompanoptions})} +\url{http://leafletjs.com/reference-1.2.0.html#zoom/pan-options})} \item{lng1, lat1, lng2, lat2}{the coordinates of the map bounds} } @@ -39,8 +45,12 @@ A series of methods to manipulate the map. \itemize{ \item \code{setView}: Set the view of the map (center and zoom level) +\item \code{flyTo}: Flys to a given location/zoom-level using smooth pan-zoom. + \item \code{fitBounds}: Set the bounds of a map +\item \code{flyToBounds}: Flys to given bound using smooth pan/zoom. + \item \code{setMaxBounds}: Restricts the map view to the given bounds \item \code{clearBounds}: Clear the bounds of a map, and the bounds will be @@ -56,5 +66,5 @@ m \%>\% fitBounds(-72, 40, -70, 43) m \%>\% clearBounds() # world view } \references{ -\url{http://leafletjs.com/reference.html#map-set-methods} +\url{http://leafletjs.com/reference-1.2.0.html#map-methods-for-modifying-map-state} } diff --git a/man/map-options.Rd b/man/map-options.Rd index b7f539fe6..0e7d5f277 100644 --- a/man/map-options.Rd +++ b/man/map-options.Rd @@ -12,10 +12,9 @@ \usage{ tileOptions(minZoom = 0, maxZoom = 18, maxNativeZoom = NULL, tileSize = 256, subdomains = "abc", errorTileUrl = "", tms = FALSE, - continuousWorld = FALSE, noWrap = FALSE, zoomOffset = 0, - zoomReverse = FALSE, opacity = 1, zIndex = 1, - unloadInvisibleTiles = NULL, updateWhenIdle = NULL, - detectRetina = FALSE, reuseTiles = FALSE, ...) + noWrap = FALSE, zoomOffset = 0, zoomReverse = FALSE, opacity = 1, + zIndex = 1, unloadInvisibleTiles = NULL, updateWhenIdle = NULL, + detectRetina = FALSE, ...) WMSTileOptions(styles = "", format = "image/jpeg", transparent = FALSE, version = "1.1.1", crs = NULL, ...) @@ -25,25 +24,25 @@ popupOptions(maxWidth = 300, minWidth = 50, maxHeight = NULL, zoomAnimation = TRUE, closeOnClick = NULL, className = "", ...) labelOptions(interactive = FALSE, clickable = NULL, noHide = NULL, - permanent = FALSE, className = "", direction = "right", offset = c(0, + permanent = FALSE, className = "", direction = "auto", offset = c(0, 0), opacity = 1, textsize = "10px", textOnly = FALSE, style = NULL, zoomAnimation = TRUE, ...) -markerOptions(clickable = TRUE, draggable = FALSE, keyboard = TRUE, - title = "", alt = "", zIndexOffset = 0, opacity = 1, - riseOnHover = FALSE, riseOffset = 250, ...) +markerOptions(interactive = TRUE, clickable = NULL, draggable = FALSE, + keyboard = TRUE, title = "", alt = "", zIndexOffset = 0, + opacity = 1, riseOnHover = FALSE, riseOffset = 250, ...) markerClusterOptions(showCoverageOnHover = TRUE, zoomToBoundsOnClick = TRUE, spiderfyOnMaxZoom = TRUE, removeOutsideVisibleBounds = TRUE, spiderLegPolylineOptions = list(weight = 1.5, color = "#222", opacity = 0.5), freezeAtZoom = FALSE, ...) -pathOptions(lineCap = NULL, lineJoin = NULL, clickable = TRUE, - pointerEvents = NULL, className = "", ...) +pathOptions(lineCap = NULL, lineJoin = NULL, clickable = NULL, + interactive = TRUE, pointerEvents = NULL, className = "", ...) } \arguments{ -\item{minZoom, maxZoom, maxNativeZoom, tileSize, subdomains, errorTileUrl, tms, continuousWorld, noWrap, zoomOffset, zoomReverse, zIndex, unloadInvisibleTiles, updateWhenIdle, detectRetina, reuseTiles}{the tile layer options; see -\url{http://leafletjs.com/reference.html#tilelayer}} +\item{minZoom, maxZoom, maxNativeZoom, tileSize, subdomains, errorTileUrl, tms, noWrap, zoomOffset, zoomReverse, zIndex, unloadInvisibleTiles, updateWhenIdle, detectRetina}{the tile layer options; see +\url{http://leafletjs.com/reference-1.2.0.html#tilelayer}} \item{...}{extra options passed to underlying Javascript object constructor.} @@ -59,15 +58,17 @@ transparency} \item{crs}{Coordinate Reference System to use for the WMS requests, defaults.} -\item{maxWidth, minWidth, maxHeight, autoPan, keepInView, closeButton, zoomAnimation, closeOnClick}{popup options; see \url{http://leafletjs.com/reference.html#popup}} +\item{maxWidth, minWidth, maxHeight, autoPan, keepInView, closeButton, zoomAnimation, closeOnClick}{popup options; see \url{http://leafletjs.com/reference-1.2.0.html#popup-option}} \item{className}{a CSS class name set on an element} -\item{clickable}{whether the element emits mouse events} +\item{interactive}{whether the element emits mouse events} -\item{noHide, direction, offset, textsize, textOnly, style}{label options; see \url{http://leafletjs.com/reference-1.0.3.html#tooltip-option}} +\item{clickable}{DEPRECATED! Use the \code{interactive} option.} -\item{draggable, keyboard, title, alt, zIndexOffset, opacity, riseOnHover, riseOffset}{marker options; see \url{http://leafletjs.com/reference.html#marker}} +\item{noHide, direction, offset, textsize, textOnly, style, permanent}{label options; see \url{http://leafletjs.com/reference-1.2.0.html#tooltip-option}} + +\item{draggable, keyboard, title, alt, zIndexOffset, opacity, riseOnHover, riseOffset}{marker options; see \url{http://leafletjs.com/reference-1.2.0.html#marker-option}} \item{showCoverageOnHover}{when you mouse over a cluster it shows the bounds of its markers} @@ -80,7 +81,7 @@ spiderfy it so you can see all of its markers} \item{removeOutsideVisibleBounds}{clusters and markers too far from the viewport are removed from the map for performance} -\item{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 }} +\item{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 }} \item{freezeAtZoom}{Allows you to freeze cluster expansion to a zoom level. Can be a zoom level e.g. 10, 12 or 'max' or 'maxKeepSpiderify' diff --git a/man/validateCoords.Rd b/man/validateCoords.Rd index 086821a27..f3e229117 100644 --- a/man/validateCoords.Rd +++ b/man/validateCoords.Rd @@ -4,7 +4,8 @@ \alias{validateCoords} \title{Utility function to check if a coordinates is valid} \usage{ -validateCoords(lng, lat, funcName, warn = T) +validateCoords(lng, lat, funcName, warn = TRUE, mode = c("point", + "polygon")) } \arguments{ \item{lng}{vector with longitude values} @@ -14,6 +15,10 @@ validateCoords(lng, lat, funcName, warn = T) \item{funcName}{Name of calling function} \item{warn}{A boolean. Whether to generate a warning message if there are rows with missing/invalid data} + +\item{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} } \description{ Utility function to check if a coordinates is valid diff --git a/tests/testit/test-remote.R b/tests/testit/test-remote.R index b1c876e14..2f28b35ee 100644 --- a/tests/testit/test-remote.R +++ b/tests/testit/test-remote.R @@ -150,7 +150,7 @@ assert( identical(mockSession$.calls, list()) ) mockSession$.flush() -expected <- list(structure(list(type = "leaflet-calls", message = structure("{\"id\":\"map\",\"calls\":[{\"dependencies\":[],\"method\":\"addPolygons\",\"args\":[[[[{\"lng\":[1,2,3,4,5],\"lat\":[1,2,3,4,5]}]]],null,null,{\"lineCap\":null,\"lineJoin\":null,\"clickable\":true,\"pointerEvents\":null,\"className\":\"\",\"stroke\":true,\"color\":\"#03F\",\"weight\":5,\"opacity\":0.5,\"fill\":true,\"fillColor\":\"#03F\",\"fillOpacity\":0.2,\"dashArray\":null,\"smoothFactor\":1,\"noClip\":false},null,null,null,null,null]}]}", class = "json")), .Names = c("type", +expected <- list(structure(list(type = "leaflet-calls", message = structure("{\"id\":\"map\",\"calls\":[{\"dependencies\":[],\"method\":\"addPolygons\",\"args\":[[[[{\"lng\":[1,2,3,4,5],\"lat\":[1,2,3,4,5]}]]],null,null,{\"interactive\":true,\"className\":\"\",\"stroke\":true,\"color\":\"#03F\",\"weight\":5,\"opacity\":0.5,\"fill\":true,\"fillColor\":\"#03F\",\"fillOpacity\":0.2,\"smoothFactor\":1,\"noClip\":false},null,null,null,null,null]}]}", class = "json")), .Names = c("type", "message"))) dput(mockSession$.calls) assert(identical(mockSession$.calls, expected)) @@ -166,7 +166,7 @@ remote2 <- leafletProxy("map", mockSession, ) # Check that addMarkers() takes effect immediately, no flush required remote2 %>% addMarkers() -expected2 <- list(list(type = "leaflet-calls", message = structure("{\"id\":\"map\",\"calls\":[{\"dependencies\":[],\"method\":\"addMarkers\",\"args\":[[10,9,8,7,6,5,4,3,2,1],[10,9,8,7,6,5,4,3,2,1],null,null,null,{\"clickable\":true,\"draggable\":false,\"keyboard\":true,\"title\":\"\",\"alt\":\"\",\"zIndexOffset\":0,\"opacity\":1,\"riseOnHover\":false,\"riseOffset\":250},null,null,null,null,null,null,null]}]}", class = "json"))) +expected2 <- list(list(type = "leaflet-calls", message = structure("{\"id\":\"map\",\"calls\":[{\"dependencies\":[],\"method\":\"addMarkers\",\"args\":[[10,9,8,7,6,5,4,3,2,1],[10,9,8,7,6,5,4,3,2,1],null,null,null,{\"interactive\":true,\"draggable\":false,\"keyboard\":true,\"title\":\"\",\"alt\":\"\",\"zIndexOffset\":0,\"opacity\":1,\"riseOnHover\":false,\"riseOffset\":250},null,null,null,null,null,null,null]}]}", class = "json"))) # cat(deparse(mockSession$.calls), "\n") assert(identical(mockSession$.calls, expected2)) # Flushing should do nothing @@ -183,7 +183,7 @@ remote3 <- leafletProxy("map", mockSession, remote3 %>% clearShapes() %>% addMarkers() assert(identical(mockSession$.calls, list())) mockSession$.flush() -expected3 <- list(structure(list(type = "leaflet-calls", message = structure("{\"id\":\"map\",\"calls\":[{\"dependencies\":[],\"method\":\"clearShapes\",\"args\":[]}]}", class = "json")), .Names = c("type", "message")), structure(list(type = "leaflet-calls", message = structure("{\"id\":\"map\",\"calls\":[{\"dependencies\":[],\"method\":\"addMarkers\",\"args\":[[10,9,8,7,6,5,4,3,2,1],[10,9,8,7,6,5,4,3,2,1],null,null,null,{\"clickable\":true,\"draggable\":false,\"keyboard\":true,\"title\":\"\",\"alt\":\"\",\"zIndexOffset\":0,\"opacity\":1,\"riseOnHover\":false,\"riseOffset\":250},null,null,null,null,null,null,null]}]}", class = "json")), .Names = c("type", "message"))) +expected3 <- list(structure(list(type = "leaflet-calls", message = structure("{\"id\":\"map\",\"calls\":[{\"dependencies\":[],\"method\":\"clearShapes\",\"args\":[]}]}", class = "json")), .Names = c("type", "message")), structure(list(type = "leaflet-calls", message = structure("{\"id\":\"map\",\"calls\":[{\"dependencies\":[],\"method\":\"addMarkers\",\"args\":[[10,9,8,7,6,5,4,3,2,1],[10,9,8,7,6,5,4,3,2,1],null,null,null,{\"interactive\":true,\"draggable\":false,\"keyboard\":true,\"title\":\"\",\"alt\":\"\",\"zIndexOffset\":0,\"opacity\":1,\"riseOnHover\":false,\"riseOffset\":250},null,null,null,null,null,null,null]}]}", class = "json")), .Names = c("type", "message"))) # Check that multiple calls are invoked in order assert(identical(mockSession$.calls, expected3)) diff --git a/tests/testthat/test-normalize-2.R b/tests/testthat/test-normalize-2.R index 0bf7f9635..427c8a883 100644 --- a/tests/testthat/test-normalize-2.R +++ b/tests/testthat/test-normalize-2.R @@ -68,6 +68,11 @@ class(do.call(rbind, unclass(st_geometry(ptsdata))) %>% st_multipoint()) # XY, expect_maps_equal(p1, p2) +(p4 <- leaflet() %>% addTiles() %>% addCircleMarkers(data = ptsdata[FALSE,])) +(p5 <- leaflet() %>% addTiles() %>% addCircleMarkers(data = st_geometry(ptsdata)[FALSE])) +(p6 <- leaflet() %>% addTiles() %>% addCircleMarkers(lng = numeric(0), lat = numeric(0))) +expect_maps_equal(p4, p5) +expect_maps_equal(p4, p6) ### lines ----------------------------------------------------------------- create_square <- function(width = 2, lng = 0, lat = 0, hole = FALSE, type = Polygon) {