From 1695722ade42ec6220077228b02693928b99915a Mon Sep 17 00:00:00 2001 From: tim-salabim Date: Sun, 22 Jan 2017 17:27:33 +0100 Subject: [PATCH 01/29] add support for simple features MULTIPOLYGON. lines to follow --- R/normalize-sf.R | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/R/normalize-sf.R b/R/normalize-sf.R index 056b09f0f..95fd28815 100644 --- a/R/normalize-sf.R +++ b/R/normalize-sf.R @@ -43,22 +43,24 @@ polygonData.sfc <- function(obj) { #' @export polygonData.MULTIPOLYGON <- function(obj) { - n <- vapply(obj, length, integer(1)) - if (any(n > 1L)) { - warning( - "leaflet currently does not support MULTIPOLYGONS. Taking first", - call. = FALSE) - } - - lapply(obj, function(x) sf_coords(x[[1]])) + unlist( + structure( + lapply(obj, function(x) lapply(x, sf_coords)), + bbox = sf_bbox(obj) + ), recursive = FALSE + ) } #' @export polygonData.MULTILINESTRING <- polygonData.MULTIPOLYGON #' @export polygonData.POLYGON <- function(obj) { - lapply(obj, sf_coords) + structure( + lapply(obj, sf_coords), + bbox = sf_bbox(obj) + ) } + #' @export polygonData.LINESTRING <- polygonData.POLYGON From 9f3e4379e84a4e5aad02fd79bd009ca7373341d2 Mon Sep 17 00:00:00 2001 From: Joe Cheng Date: Mon, 27 Feb 2017 23:35:49 -0800 Subject: [PATCH 02/29] Fix #390: validateCoords warns on valid polygon data --- R/normalize.R | 2 +- R/utils.R | 27 ++++++++++++++++++++------- man/validateCoords.Rd | 7 ++++++- 3 files changed, 27 insertions(+), 9 deletions(-) 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/utils.R b/R/utils.R index 5f2983c24..3b3f91a9f 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/man/validateCoords.Rd b/man/validateCoords.Rd index 9474c6c85..42711167c 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 From 678bae1e53030f7bb1fdb640d2984915889adfe5 Mon Sep 17 00:00:00 2001 From: Carson Sievert Date: Wed, 1 Mar 2017 16:18:36 -0600 Subject: [PATCH 03/29] ensure type safety of .indexOf(stamp); fixes #395 --- inst/htmlwidgets/leaflet.js | 3 +-- javascript/src/layer-manager.js | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/inst/htmlwidgets/leaflet.js b/inst/htmlwidgets/leaflet.js index 78317d550..19c316448 100644 --- a/inst/htmlwidgets/leaflet.js +++ b/inst/htmlwidgets/leaflet.js @@ -1097,7 +1097,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]; @@ -2348,7 +2348,6 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons // pixel of the original image has some contribution to the downscaled image) // as opposed to a single-step downscaling which will discard a lot of data // (and with sparse images at small scales can give very surprising results). - var Mipmapper = function () { function Mipmapper(img) { _classCallCheck(this, Mipmapper); diff --git a/javascript/src/layer-manager.js b/javascript/src/layer-manager.js index e9ff4ed4b..cbdfc9ca3 100644 --- a/javascript/src/layer-manager.js +++ b/javascript/src/layer-manager.js @@ -349,7 +349,7 @@ export default class LayerManager { if (layerInfo.ctGroup) { let ctGroup = this._byCrosstalkGroup[layerInfo.ctGroup]; let layersForKey = ctGroup[layerInfo.ctKey]; - let idx = layersForKey ? layersForKey.indexOf(stamp) : -1; + let idx = layersForKey ? layersForKey.indexOf(+stamp) : -1; if (idx >= 0) { if (layersForKey.length === 1) { delete ctGroup[layerInfo.ctKey]; From 298889ed6ab3404201eb157137e93808ced7378a Mon Sep 17 00:00:00 2001 From: imprompt Date: Wed, 22 Mar 2017 12:23:58 +0000 Subject: [PATCH 04/29] Add support for dragend notification --- inst/htmlwidgets/leaflet.js | 1 + javascript/src/methods.js | 1 + 2 files changed, 2 insertions(+) diff --git a/inst/htmlwidgets/leaflet.js b/inst/htmlwidgets/leaflet.js index 846125d95..be3a05736 100644 --- a/inst/htmlwidgets/leaflet.js +++ b/inst/htmlwidgets/leaflet.js @@ -1325,6 +1325,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); } }; diff --git a/javascript/src/methods.js b/javascript/src/methods.js index 8097405f5..8238bb3c3 100644 --- a/javascript/src/methods.js +++ b/javascript/src/methods.js @@ -177,6 +177,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); } } From 772065ed59ce5c6c89eaf76b724559708a308359 Mon Sep 17 00:00:00 2001 From: Joe Cheng Date: Mon, 21 Aug 2017 15:00:05 -0700 Subject: [PATCH 05/29] Update NEWS --- NEWS | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index f2e8cafd8..086468437 100644 --- a/NEWS +++ b/NEWS @@ -1,12 +1,18 @@ 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 From 32bda8e30c566ef0d6ec0b06634dde977dab2d19 Mon Sep 17 00:00:00 2001 From: Joe Cheng Date: Mon, 21 Aug 2017 15:02:50 -0700 Subject: [PATCH 06/29] Show Travis build status for master branch only --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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. From 8216a7014020cb6fd2fb32c72b6a831b7f263e27 Mon Sep 17 00:00:00 2001 From: timelyportfolio Date: Wed, 30 Aug 2017 05:58:14 -0500 Subject: [PATCH 07/29] begin update of markercluster to v0.1.1 --- .../leaflet.markercluster-src.js | 37 ++++--- .../leaflet.markercluster.freezable-src.js | 22 ++++ .../leaflet.markercluster.js | 4 +- .../leaflet.markercluster.layersupport-src.js | 103 ++++++++++++------ .../Leaflet.markercluster/package.json | 22 ++++ 5 files changed, 134 insertions(+), 54 deletions(-) create mode 100644 inst/htmlwidgets/plugins/Leaflet.markercluster/package.json diff --git a/inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster-src.js b/inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster-src.js index 983f58e09..95edd3f4d 100644 --- a/inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster-src.js +++ b/inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster-src.js @@ -54,6 +54,9 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({ if (!this.options.iconCreateFunction) { this.options.iconCreateFunction = this._defaultIconCreateFunction; } + if (!this.options.clusterPane) { + this.options.clusterPane = L.Marker.prototype.options.pane; + } this._featureGroup = L.featureGroup(); this._featureGroup.addEventParent(this); @@ -677,7 +680,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 +728,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 +921,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 +929,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 +941,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 +962,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 +1061,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 +1185,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 +1213,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 +1284,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 +1322,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 +1382,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 +1425,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 +1448,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); } }, 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..9e39bdc13 100644 --- a/inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster.freezable-src.js +++ b/inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster.freezable-src.js @@ -1,3 +1,19 @@ +/** + * Leaflet.MarkerCluster.Freezable 0.1.1+0285b6c + * 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, @@ -216,3 +232,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.js b/inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster.js index 784b8669f..1eebf5540 100644 --- a/inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster.js +++ b/inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster.js @@ -3,5 +3,5 @@ https://github.com/Leaflet/Leaflet.markercluster (c) 2012-2013, Dave Leaver, smartrak */ -!function(e,t,i){L.MarkerClusterGroup=L.FeatureGroup.extend({options:{maxClusterRadius:80,iconCreateFunction:null,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,_=!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,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.options.clusterPane||(this.options.clusterPane=L.Marker.prototype.options.pane),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,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,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/package.json b/inst/htmlwidgets/plugins/Leaflet.markercluster/package.json new file mode 100644 index 000000000..c1bde6dd4 --- /dev/null +++ b/inst/htmlwidgets/plugins/Leaflet.markercluster/package.json @@ -0,0 +1,22 @@ +{ + "name": "leaflet.markercluster", + "repository": "https://github.com/Leaflet/Leaflet.markercluster", + "version": "1.1.0", + "description": "Provides Beautiful Animated Marker Clustering functionality for Leaflet", + "devDependencies": { + "jshint": "~2.1.3", + "mocha": "~1.10.0", + "karma": "~0.8.5", + "uglify-js": "~2.3.6", + "jake": "~0.5.16", + "magic-string": "^0.7.0", + "leaflet": "~1.0.3" + }, + "main": "dist/leaflet.markercluster.js", + "scripts": { + "test": "jake test", + "prepublish": "jake" + }, + "keywords": ["gis", "map"], + "license": "MIT" +} From cced76610bf2e2f5f783be720357f204633a6ab3 Mon Sep 17 00:00:00 2001 From: timelyportfolio Date: Wed, 30 Aug 2017 06:26:30 -0500 Subject: [PATCH 08/29] update leaflet-measure to 2.1.7 --- .../lib/leaflet-measure/leaflet-measure.js | 62 ++++++++++++++++--- .../leaflet-measure/leaflet-measure.min.js | 4 +- 2 files changed, 55 insertions(+), 11 deletions(-) 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 From 167d8794ebfd19b34bc041678d63d4cb3049fb90 Mon Sep 17 00:00:00 2001 From: timelyportfolio Date: Wed, 30 Aug 2017 06:27:29 -0500 Subject: [PATCH 09/29] update leaflet-omnivore to 0.3.4 --- .../lib/leaflet-omnivore/leaflet-omnivore.js | 2382 ----------------- .../leaflet-omnivore/leaflet-omnivore.min.js | 2 +- 2 files changed, 1 insertion(+), 2383 deletions(-) delete mode 100644 inst/htmlwidgets/lib/leaflet-omnivore/leaflet-omnivore.js 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 From c60a979bfaa3af293a32f51c12db7374563a1fbb Mon Sep 17 00:00:00 2001 From: timelyportfolio Date: Wed, 30 Aug 2017 21:45:17 -0500 Subject: [PATCH 10/29] update proj4leaflet to 1.0.2 --- inst/htmlwidgets/plugins/Proj4Leaflet/proj4leaflet.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/inst/htmlwidgets/plugins/Proj4Leaflet/proj4leaflet.js b/inst/htmlwidgets/plugins/Proj4Leaflet/proj4leaflet.js index 0a550b096..eaa650c1b 100644 --- a/inst/htmlwidgets/plugins/Proj4Leaflet/proj4leaflet.js +++ b/inst/htmlwidgets/plugins/Proj4Leaflet/proj4leaflet.js @@ -15,7 +15,13 @@ factory(window.L, window.proj4); } }(function (L, proj4) { - + if (proj4.__esModule && proj4.default) { + // If proj4 was bundled as an ES6 module, unwrap it to get + // to the actual main proj4 object. + // See discussion in https://github.com/kartena/Proj4Leaflet/pull/147 + proj4 = proj4.default; + } + L.Proj = {}; L.Proj._isProj4Obj = function(a) { @@ -137,6 +143,9 @@ if (scale === downScale) { return downZoom; } + if (downScale === undefined) { + return -Infinity; + } // Interpolate nextZoom = downZoom + 1; nextScale = this._scales[nextZoom]; From 3af495a99a3d812f1cef4ca170e7138549530593 Mon Sep 17 00:00:00 2001 From: timelyportfolio Date: Wed, 30 Aug 2017 21:53:34 -0500 Subject: [PATCH 11/29] update leaflet-minimap to 3.5.0 --- .../Leaflet-MiniMap/Control.MiniMap.js | 31 ++++++++++++++++++- .../Leaflet-MiniMap/Control.MiniMap.min.js | 2 +- 2 files changed, 31 insertions(+), 2 deletions(-) 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 From fe4a794d03ad708a321e08fdf7f26249a74e38be Mon Sep 17 00:00:00 2001 From: timelyportfolio Date: Wed, 30 Aug 2017 21:58:41 -0500 Subject: [PATCH 12/29] update Leaflet.EasyButton to 2.2.2 --- .../plugins/Leaflet.EasyButton/easy-button.js | 37 +++++++------------ 1 file changed, 14 insertions(+), 23 deletions(-) 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; + }, }); From 570aff55d8a1e627ca46ed5fdfed6331f25c212b Mon Sep 17 00:00:00 2001 From: timelyportfolio Date: Wed, 30 Aug 2017 22:08:45 -0500 Subject: [PATCH 13/29] update leaflet.graticule --- .../Leaflet.Graticule/Leaflet.Graticule.js | 518 ++++++++++++++++++ 1 file changed, 518 insertions(+) create mode 100644 inst/htmlwidgets/plugins/Leaflet.Graticule/Leaflet.Graticule.js 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); +}; From 50ea1994311fa612f92738be2fd417c6be3ab6a1 Mon Sep 17 00:00:00 2001 From: Joe Cheng Date: Fri, 1 Sep 2017 12:08:40 -0700 Subject: [PATCH 14/29] Fix #452: Leaflet returns an error for empty "sf" "dataframe" objects --- DESCRIPTION | 2 +- NAMESPACE | 1 + R/normalize-sf.R | 23 +++++++++++++++++++++-- man/addAwesomeMarkers.Rd | 1 - man/addGraticule.Rd | 1 - man/addLayersControl.Rd | 1 - man/addLegend.Rd | 1 - man/addMeasure.Rd | 1 - man/addMiniMap.Rd | 1 - man/addProviderTiles.Rd | 1 - man/addRasterImage.Rd | 1 - man/addScaleBar.Rd | 3 +-- man/addSimpleGraticule.Rd | 1 - man/addTerminator.Rd | 1 - man/atlStorms2005.Rd | 1 - man/awesomeIconList.Rd | 1 - man/awesomeIcons.Rd | 1 - man/breweries91.Rd | 1 - man/colorNumeric.Rd | 4 ++-- man/deprecated.Rd | 1 - man/derivePoints.Rd | 1 - man/derivePolygons.Rd | 1 - man/dispatch.Rd | 1 - man/easyButton.Rd | 6 +++--- man/evalFormula.Rd | 1 - man/expandLimits.Rd | 1 - man/expandLimitsBbox.Rd | 1 - man/filterNULL.Rd | 1 - man/gadmCHE.Rd | 1 - man/getMapData.Rd | 1 - man/groupOptions.Rd | 1 - man/iconList.Rd | 1 - man/icons.Rd | 1 - man/leaflet.Rd | 4 ++-- man/leafletDependencies.Rd | 1 - man/leafletProxy.Rd | 1 - man/makeAwesomeIcon.Rd | 1 - man/makeIcon.Rd | 1 - man/map-layers.Rd | 20 ++++++++++---------- man/map-methods.Rd | 6 +++--- man/map-options.Rd | 8 ++++---- man/map-shiny.Rd | 1 - man/mapOptions.Rd | 1 - man/previewColors.Rd | 1 - man/providers.Rd | 1 - man/providers.details.Rd | 1 - man/remove.Rd | 30 +++++++++++++++--------------- man/safeLabel.Rd | 1 - man/showGroup.Rd | 3 +-- man/validateCoords.Rd | 1 - 50 files changed, 64 insertions(+), 84 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 60d1ce9db..2c33f680a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -64,5 +64,5 @@ Suggests: RJSONIO, purrr, testthat -RoxygenNote: 5.0.1 +RoxygenNote: 6.0.1 LazyData: true diff --git a/NAMESPACE b/NAMESPACE index add9de3e2..1c15813e9 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) 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/man/addAwesomeMarkers.Rd b/man/addAwesomeMarkers.Rd index 21e710728..d6f3a988a 100644 --- a/man/addAwesomeMarkers.Rd +++ b/man/addAwesomeMarkers.Rd @@ -60,4 +60,3 @@ initially, but can be overridden} \description{ Add Awesome Markers } - diff --git a/man/addGraticule.Rd b/man/addGraticule.Rd index a8d38bf7f..be74c8de9 100644 --- a/man/addGraticule.Rd +++ b/man/addGraticule.Rd @@ -36,4 +36,3 @@ leaf <- leaflet() \%>\% addGraticule() } - diff --git a/man/addLayersControl.Rd b/man/addLayersControl.Rd index 61cecbc1d..4c33baf60 100644 --- a/man/addLayersControl.Rd +++ b/man/addLayersControl.Rd @@ -58,4 +58,3 @@ leaflet() \%>\% } } - diff --git a/man/addLegend.Rd b/man/addLegend.Rd index d255a9f9c..78ed9a9ce 100644 --- a/man/addLegend.Rd +++ b/man/addLegend.Rd @@ -141,4 +141,3 @@ leaflet(df) \%>\% ), group='circles', position='bottomleft' ) \%>\% addLayersControl(overlayGroups = c('circles')) } - diff --git a/man/addMeasure.Rd b/man/addMeasure.Rd index 28d56d66a..c03c42586 100644 --- a/man/addMeasure.Rd +++ b/man/addMeasure.Rd @@ -79,4 +79,3 @@ leaf \%>\% addMeasure( ) } - diff --git a/man/addMiniMap.Rd b/man/addMiniMap.Rd index 68daa263b..8318e1621 100644 --- a/man/addMiniMap.Rd +++ b/man/addMiniMap.Rd @@ -87,4 +87,3 @@ leaf <- leaflet() \%>\% \seealso{ \code{\link{providers}} } - diff --git a/man/addProviderTiles.Rd b/man/addProviderTiles.Rd index 453a8888e..eef263de0 100644 --- a/man/addProviderTiles.Rd +++ b/man/addProviderTiles.Rd @@ -45,4 +45,3 @@ leaflet() \%>\% addProviderTiles("Stamen.TonerHybrid") } - diff --git a/man/addRasterImage.Rd b/man/addRasterImage.Rd index e650544fe..d51a95d3f 100644 --- a/man/addRasterImage.Rd +++ b/man/addRasterImage.Rd @@ -73,4 +73,3 @@ crs(r) <- CRS("+init=epsg:4326") leaflet() \%>\% addTiles() \%>\% addRasterImage(r, colors = "Spectral", opacity = 0.8) } - diff --git a/man/addScaleBar.Rd b/man/addScaleBar.Rd index 7eb0e3b36..ecb4cf915 100644 --- a/man/addScaleBar.Rd +++ b/man/addScaleBar.Rd @@ -2,8 +2,8 @@ % Please edit documentation in R/scalebar.R \name{addScaleBar} \alias{addScaleBar} -\alias{removeScaleBar} \alias{scaleBarOptions} +\alias{removeScaleBar} \title{Add or remove a scale bar} \usage{ addScaleBar(map, position = c("topright", "bottomright", "bottomleft", @@ -48,4 +48,3 @@ leaflet() \%>\% } } - diff --git a/man/addSimpleGraticule.Rd b/man/addSimpleGraticule.Rd index 86d4a7baa..af35567a4 100644 --- a/man/addSimpleGraticule.Rd +++ b/man/addSimpleGraticule.Rd @@ -38,4 +38,3 @@ leaflet() \%>\% addSimpleGraticule() } - diff --git a/man/addTerminator.Rd b/man/addTerminator.Rd index aaa9c2795..5fbbb446e 100644 --- a/man/addTerminator.Rd +++ b/man/addTerminator.Rd @@ -34,4 +34,3 @@ leaf <- leaflet() \%>\% addTerminator() } - diff --git a/man/atlStorms2005.Rd b/man/atlStorms2005.Rd index a5e9595ce..3271bfb9b 100644 --- a/man/atlStorms2005.Rd +++ b/man/atlStorms2005.Rd @@ -12,4 +12,3 @@ Atlantic Ocean storms 2005 This dataset contains storm tracks for selected storms in the Atlantic Ocean basin for the year 2005 } - diff --git a/man/awesomeIconList.Rd b/man/awesomeIconList.Rd index ad5a3614a..c66fafeaa 100644 --- a/man/awesomeIconList.Rd +++ b/man/awesomeIconList.Rd @@ -21,4 +21,3 @@ iconSet = awesomeIconList( iconSet[c('home', 'flag')] } - diff --git a/man/awesomeIcons.Rd b/man/awesomeIcons.Rd index f7f5ad1b3..bdd4fa46d 100644 --- a/man/awesomeIcons.Rd +++ b/man/awesomeIcons.Rd @@ -47,4 +47,3 @@ An icon can be represented as a list of the form \code{list(icon, library, icon data. Shorter argument values will be re-cycled. \code{NULL} values for these arguments will be ignored. } - diff --git a/man/breweries91.Rd b/man/breweries91.Rd index 3aabdfcde..a58f0d4e7 100644 --- a/man/breweries91.Rd +++ b/man/breweries91.Rd @@ -14,4 +14,3 @@ subset of a larger database that was compiled by students at the University of Marburg for a seminar called "The Geography of Beer, sustainability in the food industry" } - diff --git a/man/colorNumeric.Rd b/man/colorNumeric.Rd index e16965849..6536ddae9 100644 --- a/man/colorNumeric.Rd +++ b/man/colorNumeric.Rd @@ -1,10 +1,11 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/colors.R \name{colorNumeric} +\alias{colorNumeric} \alias{colorBin} +\alias{colorQuantile} \alias{colorFactor} \alias{colorNumeric} -\alias{colorQuantile} \title{Color mapping} \usage{ colorNumeric(palette, domain, na.color = "#808080", alpha = FALSE, @@ -120,4 +121,3 @@ previewColors(colorFactor("RdYlBu", domain = NULL), factor(LETTERS[1:5], levels= previewColors(colorFactor("RdYlBu", levels = LETTERS), LETTERS[1:5]) } } - diff --git a/man/deprecated.Rd b/man/deprecated.Rd index 6290db916..62f74d6f4 100644 --- a/man/deprecated.Rd +++ b/man/deprecated.Rd @@ -21,4 +21,3 @@ These functions are provided for backwards compatibility with the first iteration of the leaflet bindings (\url{https://github.com/jcheng5/leaflet-shiny}). } - diff --git a/man/derivePoints.Rd b/man/derivePoints.Rd index 557298e40..29ad9c930 100644 --- a/man/derivePoints.Rd +++ b/man/derivePoints.Rd @@ -27,4 +27,3 @@ Given a data object and lng/lat arguments (which may be NULL [meaning infer from data], formula [which should be evaluated with respect to the data], or vector data [which should be used as-is]) return a lng/lat data frame. } - diff --git a/man/derivePolygons.Rd b/man/derivePolygons.Rd index 495122184..39d254de7 100644 --- a/man/derivePolygons.Rd +++ b/man/derivePolygons.Rd @@ -27,4 +27,3 @@ Given a data object and lng/lat arguments (which may be NULL [meaning infer from data], formula [which should be evaluated with respect to the data], or vector data [which should be used as-is]) return a spatial object } - diff --git a/man/dispatch.Rd b/man/dispatch.Rd index 5095ec4c5..af4a5016c 100644 --- a/man/dispatch.Rd +++ b/man/dispatch.Rd @@ -39,4 +39,3 @@ this \code{dispatch} call; for error message purposes} \description{ Extension points for plugins } - diff --git a/man/easyButton.Rd b/man/easyButton.Rd index 1ad708081..9e6c27623 100644 --- a/man/easyButton.Rd +++ b/man/easyButton.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/plugin-easybutton.R \name{easyButtonState} +\alias{easyButtonState} +\alias{easyButton} \alias{addEasyButton} \alias{addEasyButtonBar} -\alias{easyButton} -\alias{easyButtonState} \title{Create an easyButton statestate} \usage{ easyButtonState(stateName, icon, title, onClick) @@ -56,6 +56,7 @@ see \url{https://github.com/CliffCloud/Leaflet.EasyButton} \item \code{addEasyButtonBar}: add an EasyButton to the map }} + \examples{ library(leaflet) @@ -86,4 +87,3 @@ leaf <- leaflet() \%>\% \code{\link{addEasyButton}} } - diff --git a/man/evalFormula.Rd b/man/evalFormula.Rd index 646ed44b1..4636fab64 100644 --- a/man/evalFormula.Rd +++ b/man/evalFormula.Rd @@ -16,4 +16,3 @@ evalFormula(list, data) Evaluate list members that are formulae, using the map data as the environment (if provided, otherwise the formula environment) } - diff --git a/man/expandLimits.Rd b/man/expandLimits.Rd index f41eac401..27d0cf519 100644 --- a/man/expandLimits.Rd +++ b/man/expandLimits.Rd @@ -16,4 +16,3 @@ expandLimits(map, lat, lng) \description{ Notifies the map of new latitude/longitude of items of interest on the map } - diff --git a/man/expandLimitsBbox.Rd b/man/expandLimitsBbox.Rd index d6fca7a26..05b2b0cdb 100644 --- a/man/expandLimitsBbox.Rd +++ b/man/expandLimitsBbox.Rd @@ -16,4 +16,3 @@ expandLimitsBbox(map, poly) Same as expandLimits, but takes a polygon (that presumably has a bbox attr) rather than lat/lng. } - diff --git a/man/filterNULL.Rd b/man/filterNULL.Rd index e084e4b1f..1204a08be 100644 --- a/man/filterNULL.Rd +++ b/man/filterNULL.Rd @@ -12,4 +12,3 @@ filterNULL(x) \description{ remove NULL elements from a list } - diff --git a/man/gadmCHE.Rd b/man/gadmCHE.Rd index 413e3f26e..1aef55318 100644 --- a/man/gadmCHE.Rd +++ b/man/gadmCHE.Rd @@ -15,4 +15,3 @@ Administrative borders of Switzerland (level 1) This dataset comes from \url{http://gadm.org}. It was downloaded using \code{\link{getData}}. } - diff --git a/man/getMapData.Rd b/man/getMapData.Rd index 94a17b5b0..bb2894fa3 100644 --- a/man/getMapData.Rd +++ b/man/getMapData.Rd @@ -12,4 +12,3 @@ getMapData(map) \description{ returns the map's data } - diff --git a/man/groupOptions.Rd b/man/groupOptions.Rd index 5c996e3fb..714676b7d 100644 --- a/man/groupOptions.Rd +++ b/man/groupOptions.Rd @@ -36,4 +36,3 @@ leaflet() \%>\% groupOptions("detail", zoomLevels = 7:18) } - diff --git a/man/iconList.Rd b/man/iconList.Rd index b4be78627..4bd2c2411 100644 --- a/man/iconList.Rd +++ b/man/iconList.Rd @@ -21,4 +21,3 @@ iconSet = iconList( iconSet[c('red', 'green', 'red')] } - diff --git a/man/icons.Rd b/man/icons.Rd index e44664e4f..e4062d905 100644 --- a/man/icons.Rd +++ b/man/icons.Rd @@ -114,4 +114,3 @@ leaflet() \%>\% addMarkers( unlink(iconFiles) # clean up the tmp png files that have been embedded } - diff --git a/man/leaflet.Rd b/man/leaflet.Rd index 755a74c81..e27097d3e 100644 --- a/man/leaflet.Rd +++ b/man/leaflet.Rd @@ -2,8 +2,8 @@ % Please edit documentation in R/leaflet.R \name{leaflet} \alias{leaflet} -\alias{leafletCRS} \alias{leafletOptions} +\alias{leafletCRS} \title{Create a Leaflet map widget} \usage{ leaflet(data = NULL, width = NULL, height = NULL, padding = 0, @@ -97,6 +97,7 @@ formulae will be evaluated in the \code{data}. \item \code{leafletCRS}: class to create a custom CRS }} + \examples{ # !formatR library(leaflet) @@ -262,4 +263,3 @@ m \%>\% addCircleMarkers(~lng, ~lat, radius = ~size, \url{http://leafletjs.com/reference.html#map-options} for details. } - diff --git a/man/leafletDependencies.Rd b/man/leafletDependencies.Rd index 25884f0c7..54d8959ad 100644 --- a/man/leafletDependencies.Rd +++ b/man/leafletDependencies.Rd @@ -20,4 +20,3 @@ addBootStrap <- function(map) { } } \keyword{datasets} - diff --git a/man/leafletProxy.Rd b/man/leafletProxy.Rd index d01619128..cec845f12 100644 --- a/man/leafletProxy.Rd +++ b/man/leafletProxy.Rd @@ -72,4 +72,3 @@ shinyApp(ui, server) } } - diff --git a/man/makeAwesomeIcon.Rd b/man/makeAwesomeIcon.Rd index b94e8a5f7..a3309aea7 100644 --- a/man/makeAwesomeIcon.Rd +++ b/man/makeAwesomeIcon.Rd @@ -40,4 +40,3 @@ argument of \code{\link{addAwesomeMarkers}()}.} \description{ Make Awesome Icon } - diff --git a/man/makeIcon.Rd b/man/makeIcon.Rd index 2ce44dbd8..04272949b 100644 --- a/man/makeIcon.Rd +++ b/man/makeIcon.Rd @@ -54,4 +54,3 @@ popups will "open", relative to the icon anchor} \description{ Define icon sets } - diff --git a/man/map-layers.Rd b/man/map-layers.Rd index 0d53a911b..fb991f6ba 100644 --- a/man/map-layers.Rd +++ b/man/map-layers.Rd @@ -1,20 +1,20 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/controls.R, R/layers.R, R/plugin-omnivore.R \name{addControl} -\alias{addCircleMarkers} -\alias{addCircles} \alias{addControl} -\alias{addGeoJSON} -\alias{addLabelOnlyMarkers} +\alias{addTiles} +\alias{addWMSTiles} +\alias{addPopups} \alias{addMarkers} -\alias{addPolygons} +\alias{addLabelOnlyMarkers} +\alias{addCircleMarkers} +\alias{highlightOptions} +\alias{addCircles} \alias{addPolylines} -\alias{addPopups} \alias{addRectangles} -\alias{addTiles} +\alias{addPolygons} +\alias{addGeoJSON} \alias{addTopoJSON} -\alias{addWMSTiles} -\alias{highlightOptions} \title{Graphics elements and layers} \usage{ addControl(map, html, position = c("topleft", "topright", "bottomleft", @@ -241,6 +241,7 @@ Options to highlight shapes (polylines/polygons/circles/rectangles) \item \code{addTopoJSON}: Add TopoJSON layers to the map }} + \references{ The Leaflet API documentation: \url{http://leafletjs.com/reference.html} @@ -250,4 +251,3 @@ The Leaflet API documentation: \code{\link{popupOptions}}, \code{\link{markerOptions}}, \code{\link{pathOptions}} } - diff --git a/man/map-methods.Rd b/man/map-methods.Rd index 010af837c..5c05c846b 100644 --- a/man/map-methods.Rd +++ b/man/map-methods.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/methods.R \name{setView} -\alias{clearBounds} +\alias{setView} \alias{fitBounds} \alias{setMaxBounds} -\alias{setView} +\alias{clearBounds} \title{Methods to manipulate the map widget} \usage{ setView(map, lng, lat, zoom, options = list()) @@ -47,6 +47,7 @@ A series of methods to manipulate the map. automatically determined from latitudes and longitudes of the map elements if available (otherwise the full world view is used) }} + \examples{ library(leaflet) m = leaflet() \%>\% addTiles() \%>\% setView(-71.0382679, 42.3489054, zoom = 18) @@ -57,4 +58,3 @@ m \%>\% clearBounds() # world view \references{ \url{http://leafletjs.com/reference.html#map-set-methods} } - diff --git a/man/map-options.Rd b/man/map-options.Rd index c119ab3ab..2a8680227 100644 --- a/man/map-options.Rd +++ b/man/map-options.Rd @@ -1,13 +1,13 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/layers.R \name{tileOptions} +\alias{tileOptions} \alias{WMSTileOptions} +\alias{popupOptions} \alias{labelOptions} -\alias{markerClusterOptions} \alias{markerOptions} +\alias{markerClusterOptions} \alias{pathOptions} -\alias{popupOptions} -\alias{tileOptions} \title{Extra options for map elements and layers} \usage{ tileOptions(minZoom = 0, maxZoom = 18, maxNativeZoom = NULL, @@ -118,8 +118,8 @@ listed in the layer functions. \item \code{pathOptions}: Options for vector layers (polylines, polygons, rectangles, and circles, etc) }} + \seealso{ \code{\link{leafletCRS}} to map CRS (don't change this if you're not sure what it means) } - diff --git a/man/map-shiny.Rd b/man/map-shiny.Rd index 6a65fc999..bd38a6a76 100644 --- a/man/map-shiny.Rd +++ b/man/map-shiny.Rd @@ -40,4 +40,3 @@ app = shinyApp( if (interactive()) print(app)} } - diff --git a/man/mapOptions.Rd b/man/mapOptions.Rd index 2089402be..019dcd5a4 100644 --- a/man/mapOptions.Rd +++ b/man/mapOptions.Rd @@ -26,4 +26,3 @@ leaflet() \%>\% addPopups(174.7690922, -36.8523071, 'R was born here!') \%>\% mapOptions(zoomToLimits = "first") } - diff --git a/man/previewColors.Rd b/man/previewColors.Rd index 9214856b9..507f76024 100644 --- a/man/previewColors.Rd +++ b/man/previewColors.Rd @@ -17,4 +17,3 @@ An HTML-based list of the colors and values \description{ Color previewing utility } - diff --git a/man/providers.Rd b/man/providers.Rd index e038d57f7..7a093b66b 100644 --- a/man/providers.Rd +++ b/man/providers.Rd @@ -15,4 +15,3 @@ providers List of all providers with their variations } \keyword{datasets} - diff --git a/man/providers.details.Rd b/man/providers.details.Rd index 5d749a778..707ecee27 100644 --- a/man/providers.details.Rd +++ b/man/providers.details.Rd @@ -15,4 +15,3 @@ providers.details List of all providers with their variations and additional info } \keyword{datasets} - diff --git a/man/remove.Rd b/man/remove.Rd index 2edab9e1a..21cfcb925 100644 --- a/man/remove.Rd +++ b/man/remove.Rd @@ -1,28 +1,29 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/controls.R, R/layers.R, R/plugin-measure.R, R/plugin-omnivore.R +% Please edit documentation in R/controls.R, R/layers.R, R/plugin-measure.R, +% R/plugin-omnivore.R \name{removeControl} +\alias{removeControl} \alias{clearControls} -\alias{clearGeoJSON} \alias{clearGroup} +\alias{removeImage} \alias{clearImages} -\alias{clearMarkerClusters} -\alias{clearMarkers} -\alias{clearPopups} -\alias{clearShapes} -\alias{clearTiles} -\alias{clearTopoJSON} \alias{remove} -\alias{removeControl} -\alias{removeGeoJSON} -\alias{removeImage} +\alias{removeTiles} +\alias{clearTiles} +\alias{removePopup} +\alias{clearPopups} \alias{removeMarker} +\alias{clearMarkers} \alias{removeMarkerCluster} +\alias{clearMarkerClusters} \alias{removeMarkerFromCluster} -\alias{removeMeasure} -\alias{removePopup} \alias{removeShape} -\alias{removeTiles} +\alias{clearShapes} +\alias{removeGeoJSON} +\alias{clearGeoJSON} +\alias{removeMeasure} \alias{removeTopoJSON} +\alias{clearTopoJSON} \title{Remove elements from a map} \usage{ removeControl(map, layerId) @@ -100,4 +101,3 @@ When used with a \code{\link{leaflet}}() map object, these functions WMS tile layers are extensions of tile layers, so they can also be removed or cleared via \code{removeTiles()} or \code{clearTiles()}. } - diff --git a/man/safeLabel.Rd b/man/safeLabel.Rd index 10d356cfe..b8badb721 100644 --- a/man/safeLabel.Rd +++ b/man/safeLabel.Rd @@ -18,4 +18,3 @@ labels. It prevents strings from unintentionally being treated as HTML when they are intended to be plaintext. } \keyword{internal} - diff --git a/man/showGroup.Rd b/man/showGroup.Rd index da61c683c..35b5e7511 100644 --- a/man/showGroup.Rd +++ b/man/showGroup.Rd @@ -1,8 +1,8 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/layers.R \name{showGroup} -\alias{hideGroup} \alias{showGroup} +\alias{hideGroup} \title{Show or hide layer groups} \usage{ showGroup(map, group) @@ -23,4 +23,3 @@ adding functions. \code{\link{addLayersControl}} to allow users to show/hide layer groups interactively } - diff --git a/man/validateCoords.Rd b/man/validateCoords.Rd index 9474c6c85..086821a27 100644 --- a/man/validateCoords.Rd +++ b/man/validateCoords.Rd @@ -18,4 +18,3 @@ validateCoords(lng, lat, funcName, warn = T) \description{ Utility function to check if a coordinates is valid } - From 58aaf509262185c13b2a1f24986e219c13bc6513 Mon Sep 17 00:00:00 2001 From: Joe Cheng Date: Fri, 1 Sep 2017 12:24:25 -0700 Subject: [PATCH 15/29] Add unit tests for empty sf --- tests/testthat/test-normalize-2.R | 5 +++++ 1 file changed, 5 insertions(+) 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) { From 766842874f62a3371a4aca3606b8b2b75fb9a9ce Mon Sep 17 00:00:00 2001 From: tim-salabim Date: Sat, 9 Sep 2017 11:02:29 +0200 Subject: [PATCH 16/29] delete local version of normalize-sf --- R/normalize-sf.R | 100 ----------------------------------------------- 1 file changed, 100 deletions(-) delete mode 100644 R/normalize-sf.R diff --git a/R/normalize-sf.R b/R/normalize-sf.R deleted file mode 100644 index 95fd28815..000000000 --- a/R/normalize-sf.R +++ /dev/null @@ -1,100 +0,0 @@ -# metaData ---------------------------------------------------------------- - -#' @export -metaData.sf <- function(obj) { - obj -} - -# pointsData -------------------------------------------------------------- - -#' @export -pointData.sf <- function(obj) { - geometry <- obj[[attr(obj, "sf_column")]] - pointData(geometry) -} - -#' @export -pointData.sfc_POINT <- function(obj) { - check_crs(obj) - - structure( - sf_coords(do.call("rbind", obj)), - bbox = sf_bbox(obj) - ) -} - -# polygonData ------------------------------------------------------------- - -#' @export -polygonData.sf <- function(obj) { - geometry <- obj[[attr(obj, "sf_column")]] - polygonData(geometry) -} - -#' @export -polygonData.sfc <- function(obj) { - check_crs(obj) - - structure( - lapply(obj, polygonData), - bbox = sf_bbox(obj) - ) -} - -#' @export -polygonData.MULTIPOLYGON <- function(obj) { - unlist( - structure( - lapply(obj, function(x) lapply(x, sf_coords)), - bbox = sf_bbox(obj) - ), recursive = FALSE - ) -} -#' @export -polygonData.MULTILINESTRING <- polygonData.MULTIPOLYGON - -#' @export -polygonData.POLYGON <- function(obj) { - structure( - lapply(obj, sf_coords), - bbox = sf_bbox(obj) - ) -} - -#' @export -polygonData.LINESTRING <- polygonData.POLYGON - - -# helpers ----------------------------------------------------------------- - -check_crs <- function(x) { - crs <- sf::st_crs(x) - - # Don't have enough information to check - if (is.na(crs)) - return() - - if (identical(sf::st_is_longlat(x), FALSE)) { - warning("sf layer is not long-lat data", call. = FALSE) - } - - if (!grepl("+datum=WGS84", crs$proj4string, fixed = TRUE)) { - warning( - "sf layer has inconsistent datum (", crs$proj4string, ").\n", - "Need '+proj=longlat +datum=WGS84'", - call. = FALSE - ) - } - -} - -sf_coords <- function(x) { - structure( - as.data.frame(x), - names = c("lng", "lat") - ) -} - -sf_bbox <- function(x) { - matrix(sf::st_bbox(x), ncol = 2, byrow = FALSE) -} From 0102062e4f730ed5b975b477c857a52255b7b14d Mon Sep 17 00:00:00 2001 From: tim-salabim Date: Sat, 9 Sep 2017 13:18:25 +0200 Subject: [PATCH 17/29] add method argument to addRasterImage, fixes #219 and #461. --- R/layers.R | 16 +++++++++++++--- man/addRasterImage.Rd | 9 +++++++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/R/layers.R b/R/layers.R index 1bead2d20..0a589b9d9 100644 --- a/R/layers.R +++ b/R/layers.R @@ -209,6 +209,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 +235,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 +272,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 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.} } From 480e15a08ba703eb2a83c64f316f301e98697e68 Mon Sep 17 00:00:00 2001 From: tim-salabim Date: Sat, 9 Sep 2017 13:19:09 +0200 Subject: [PATCH 18/29] add argument elementId to leaflet. fixes #411 --- R/leaflet.R | 8 ++++++-- man/leaflet.Rd | 5 ++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/R/leaflet.R b/R/leaflet.R index 427f81c29..8841f6801 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)) { diff --git a/man/leaflet.Rd b/man/leaflet.Rd index e27097d3e..98f4df6b6 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.} From ada5aa6a43ee7cac1c572e54271d5902d0b7d419 Mon Sep 17 00:00:00 2001 From: timelyportfolio Date: Thu, 28 Sep 2017 06:19:59 -0500 Subject: [PATCH 19/29] attempt to resolve cluster layer support and freezable conflict --- .../leaflet.markercluster.freezable-src.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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 9e39bdc13..6892bd7fb 100644 --- a/inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster.freezable-src.js +++ b/inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster.freezable-src.js @@ -16,12 +16,12 @@ 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) { @@ -167,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); @@ -216,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, @@ -237,4 +243,4 @@ L.MarkerClusterGroup.include({ })); -//# sourceMappingURL=leaflet.markercluster.freezable-src.map \ No newline at end of file +//# sourceMappingURL=leaflet.markercluster.freezable-src.map From d40024c917ec1350a77dda22e84781568ed2176d Mon Sep 17 00:00:00 2001 From: timelyportfolio Date: Fri, 29 Sep 2017 06:10:49 -0500 Subject: [PATCH 20/29] change order of load for freezable and layersupport to get freeze working again --- R/layers.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/layers.R b/R/layers.R index 39e1af148..31cfed66a 100644 --- a/R/layers.R +++ b/R/layers.R @@ -633,7 +633,7 @@ markerClusterDependencies <- function() { 'leaflet-markercluster', '1.0.4', 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-src.js', 'leaflet.markercluster.layersupport-src.js'), stylesheet = c('MarkerCluster.css', 'MarkerCluster.Default.css') ) ) From 57d634964b3496d002989da1de5e7994f9cb882f Mon Sep 17 00:00:00 2001 From: Bhaskar Karambelkar Date: Sun, 5 Nov 2017 22:25:48 -0500 Subject: [PATCH 21/29] #453 + #458 + Fix for locationfilter + latest plugins --- R/layers.R | 2 +- R/plugin-measure.R | 2 +- R/plugin-providers.R | 2 +- R/selection.R | 2 +- inst/htmlwidgets/leaflet.yaml | 2 +- .../lib/leaflet-providers/bower.json | 2 +- .../leaflet-providers/leaflet-providers.js | 56 +++++++++++++++---- .../lib/leaflet-providers/package.json | 12 ++-- .../leaflet.markercluster-src.js | 12 ++-- .../leaflet.markercluster.freezable-src.js | 4 +- .../leaflet.markercluster.freezable.js | 6 ++ .../leaflet.markercluster.js | 4 +- ...flet.markercluster.layersupport-src.js.map | 1 + .../leaflet.markercluster.layersupport.js | 6 ++ .../leaflet-locationfilter/locationfilter.css | 41 ++++++-------- .../leaflet-locationfilter/locationfilter.js | 2 +- 16 files changed, 96 insertions(+), 60 deletions(-) create mode 100644 inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster.freezable.js create mode 100644 inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster.layersupport-src.js.map create mode 100644 inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster.layersupport.js diff --git a/R/layers.R b/R/layers.R index 31cfed66a..a5e2ee08e 100644 --- a/R/layers.R +++ b/R/layers.R @@ -631,7 +631,7 @@ 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.freezable-src.js', 'leaflet.markercluster.layersupport-src.js'), stylesheet = c('MarkerCluster.css', 'MarkerCluster.Default.css') diff --git a/R/plugin-measure.R b/R/plugin-measure.R index 2c3880cd5..171c30944 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" diff --git a/R/plugin-providers.R b/R/plugin-providers.R index 27d20e815..d8499c6cf 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" ), 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/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-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..a29e04d25 100644 --- a/inst/htmlwidgets/lib/leaflet-providers/leaflet-providers.js +++ b/inst/htmlwidgets/lib/leaflet-providers/leaflet-providers.js @@ -110,7 +110,7 @@ } }, DE: { - url: 'http://{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png', + url: '//{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png', options: { maxZoom: 18 } @@ -144,30 +144,29 @@ } }, Thunderforest: { - url: '//{s}.tile.thunderforest.com/{variant}/{z}/{x}/{y}.png', + url: '//{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', @@ -201,6 +200,7 @@ Hydda: { url: '//{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}' }, @@ -216,7 +216,9 @@ attribution: 'Imagery from MapBox — ' + 'Map data {attribution.OpenStreetMap}', - subdomains: 'abcd' + subdomains: 'abcd', + id: 'streets', + accessToken: '', } }, Stamen: { @@ -528,7 +530,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 +540,12 @@ variant: 'geolandbasemap' }, variants: { - basemap: 'geolandbasemap', + basemap: { + options: { + maxZoom: 20, // currently only in Vienna + variant: 'geolandbasemap' + } + }, grau: 'bmapgrau', overlay: 'bmapoverlay', highdpi: { @@ -549,6 +556,7 @@ }, orthofoto: { options: { + maxZoom: 20, // currently only in Vienna variant: 'bmaporthofoto30cm', format: 'jpeg' } @@ -628,6 +636,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/plugins/Leaflet.markercluster/leaflet.markercluster-src.js b/inst/htmlwidgets/plugins/Leaflet.markercluster/leaflet.markercluster-src.js index 95edd3f4d..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, @@ -54,9 +55,6 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({ if (!this.options.iconCreateFunction) { this.options.iconCreateFunction = this._defaultIconCreateFunction; } - if (!this.options.clusterPane) { - this.options.clusterPane = L.Marker.prototype.options.pane; - } this._featureGroup = L.featureGroup(); this._featureGroup.addEventParent(this); @@ -1900,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; } @@ -1913,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 6892bd7fb..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,5 +1,5 @@ /** - * Leaflet.MarkerCluster.Freezable 0.1.1+0285b6c + * 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 @@ -243,4 +243,4 @@ L.MarkerClusterGroup.include({ })); -//# sourceMappingURL=leaflet.markercluster.freezable-src.map +//# 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,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,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,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() +!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.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 Date: Sun, 5 Nov 2017 22:39:33 -0500 Subject: [PATCH 22/29] grunt build after merging PRs --- inst/htmlwidgets/leaflet.js | 1 + 1 file changed, 1 insertion(+) diff --git a/inst/htmlwidgets/leaflet.js b/inst/htmlwidgets/leaflet.js index 1916d50fc..1b71de8eb 100644 --- a/inst/htmlwidgets/leaflet.js +++ b/inst/htmlwidgets/leaflet.js @@ -2423,6 +2423,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons // pixel of the original image has some contribution to the downscaled image) // as opposed to a single-step downscaling which will discard a lot of data // (and with sparse images at small scales can give very surprising results). + var Mipmapper = function () { function Mipmapper(img) { _classCallCheck(this, Mipmapper); From 307326ba69ee26ac0143745ce0e43f665163dc09 Mon Sep 17 00:00:00 2001 From: Bhaskar Karambelkar Date: Sun, 5 Nov 2017 23:55:49 -0500 Subject: [PATCH 23/29] Minor fixes/documentation, and example updates --- .Rbuildignore | 2 ++ DESCRIPTION | 2 +- R/layers.R | 4 ++-- inst/examples/awesomeMarkers.R | 6 +++--- inst/examples/easyButton.R | 4 ++-- inst/examples/geojson.R | 2 +- inst/examples/labels.R | 2 +- inst/examples/leaflet-measure.R | 2 +- inst/examples/legend.R | 2 +- inst/examples/marker-clustering.R | 4 ++-- inst/examples/minimap.R | 4 ++-- inst/examples/polarProjections.R | 2 +- inst/examples/proj4Leaflet.R | 4 ++-- inst/examples/simpleGraticule.R | 2 +- inst/examples/terminator.R | 8 ++++---- inst/htmlwidgets/leaflet.js | 4 +++- inst/htmlwidgets/lib/leaflet/images/1px.png | Bin 0 -> 68 bytes javascript/src/crs_utils.js | 6 ++++-- man/addLegend.Rd | 2 +- man/map-options.Rd | 2 +- 20 files changed, 35 insertions(+), 29 deletions(-) create mode 100644 inst/htmlwidgets/lib/leaflet/images/1px.png diff --git a/.Rbuildignore b/.Rbuildignore index 5baf76052..c0b6e459c 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -13,3 +13,5 @@ ^package\.json$ ^node_modules$ ^data-raw$ +^npm-shrinkwrap\.json$ +^\.Rprofile\.local$ 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/R/layers.R b/R/layers.R index 7d85053b5..e7d52463e 100644 --- a/R/layers.R +++ b/R/layers.R @@ -506,8 +506,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,interactive,permanent +#' label options; see \url{http://leafletjs.com/reference-1.2.0.html#tooltip-option} #' @describeIn map-options Options for labels #' @export labelOptions <- function( diff --git a/inst/examples/awesomeMarkers.R b/inst/examples/awesomeMarkers.R index 7e076b77a..c26a02ec8 100644 --- a/inst/examples/awesomeMarkers.R +++ b/inst/examples/awesomeMarkers.R @@ -51,7 +51,7 @@ library(dplyr) cities <- cities %>% mutate(PopCat=ifelse(Pop <500000,'blue','red')) -leaflet(cities) %>% addTiles() %>% +leaflet(cities) %>% addProviderTiles(providers$OpenStreetMap) %>% addAwesomeMarkers(lng = ~Long, lat = ~Lat, label = ~City, icon = icon.ion) @@ -61,7 +61,7 @@ icon.pop <- awesomeIcons(icon = 'users', library = 'fa', iconColor = 'black') -leaflet(cities) %>% addTiles() %>% +leaflet(cities) %>% addProviderTiles(providers$OpenStreetMap) %>% addAwesomeMarkers(lng = ~Long, lat = ~Lat, label = ~City, icon = icon.pop) @@ -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/easyButton.R b/inst/examples/easyButton.R index 91a97de1e..db48c9a52 100644 --- a/inst/examples/easyButton.R +++ b/inst/examples/easyButton.R @@ -3,7 +3,7 @@ library(leaflet) #' Add two easy buttons. #' first to set zoom level to 1, #' second to find your self -leaflet() %>% addTiles() %>% +leaflet() %>% addProviderTiles(providers$OpenStreetMap) %>% addEasyButton(easyButton( icon='fa-globe', title='Zoom to Level 1', onClick=JS("function(btn, map){ map.setZoom(1);}"))) %>% @@ -12,7 +12,7 @@ leaflet() %>% addTiles() %>% onClick=JS("function(btn, map){ map.locate({setView: true});}"))) #'

Toggle Button to freeze/unfreeze clustering at a zoom level. -leaflet() %>% addTiles() %>% +leaflet() %>% addProviderTiles(providers$OpenStreetMap) %>% addMarkers(data=quakes, clusterOptions = markerClusterOptions(), clusterId = 'quakesCluster') %>% diff --git a/inst/examples/geojson.R b/inst/examples/geojson.R index 6f48f1148..5d92e96c2 100644 --- a/inst/examples/geojson.R +++ b/inst/examples/geojson.R @@ -19,7 +19,7 @@ icons <- awesomeIconList( restaurant = makeAwesomeIcon(icon='cutlery', library='fa', markerColor = 'blue') ) -leaflet() %>% addTiles() %>% +leaflet() %>% addProviderTiles(providers$OpenStreetMap) %>% setView(10.758276373601069, 59.92448055859924, 13) %>% addAwesomeMarkers(data=spdf, label=~stringr::str_c(amenity,': ', name), 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/leaflet-measure.R b/inst/examples/leaflet-measure.R index 2799c7d99..adf90af65 100644 --- a/inst/examples/leaflet-measure.R +++ b/inst/examples/leaflet-measure.R @@ -1,7 +1,7 @@ library(leaflet) leaf <- leaflet() %>% - addTiles() + addProviderTiles(providers$OpenStreetMap) #'
#' Default Behavior diff --git a/inst/examples/legend.R b/inst/examples/legend.R index 0309eb309..f42fb2631 100644 --- a/inst/examples/legend.R +++ b/inst/examples/legend.R @@ -1,7 +1,7 @@ # !formatR library(leaflet) # a manual legend -leaflet() %>% addTiles() %>% addLegend( +leaflet() %>% addProviderTiles(providers$OpenStreetMap) %>% addLegend( position = 'bottomright', colors = rgb(t(col2rgb(palette())) / 255), labels = palette(), opacity = 1, diff --git a/inst/examples/marker-clustering.R b/inst/examples/marker-clustering.R index 944471aa5..fdb7a6afc 100644 --- a/inst/examples/marker-clustering.R +++ b/inst/examples/marker-clustering.R @@ -5,7 +5,7 @@ quakes <- quakes %>% dplyr::mutate(mag.level = cut(mag,c(3,4,5,6), labels = c('>3 & <=4', '>4 & <=5', '>5 & <=6'))) -l <- leaflet() %>% addTiles() +l <- leaflet() %>% addProviderTiles(providers$OpenStreetMap) #'

#' Default Clustering @@ -52,7 +52,7 @@ l2 %>% #'

#' Clustering with custom iconCreateFunction -leaflet(quakes) %>% addTiles() %>% +leaflet(quakes) %>% addProviderTiles(providers$OpenStreetMap) %>% addMarkers(clusterOptions = markerClusterOptions(iconCreateFunction = JS(" diff --git a/inst/examples/minimap.R b/inst/examples/minimap.R index 241ca753f..6542e12fe 100644 --- a/inst/examples/minimap.R +++ b/inst/examples/minimap.R @@ -3,7 +3,7 @@ library(leaflet) l <- leaflet() %>% setView(0,0,3) #' Default Minimap -l %>% addTiles() %>% addMiniMap() +l %>% addProviderTiles(providers$OpenStreetMap) %>% addMiniMap() #'
#' Different basemap for the minimap and togglable @@ -62,7 +62,7 @@ icons <- awesomeIconList( restaurant = makeAwesomeIcon(icon='cutlery', library='fa', markerColor = 'blue') ) -leaflet() %>% addTiles() %>% +leaflet() %>% addProviderTiles(providers$OpenStreetMap) %>% setView(10.758276373601069, 59.92448055859924, 13) %>% addAwesomeMarkers(data=spdf, label=~stringr::str_c(amenity,': ', name), diff --git a/inst/examples/polarProjections.R b/inst/examples/polarProjections.R index 37aa51120..befb2f1bf 100644 --- a/inst/examples/polarProjections.R +++ b/inst/examples/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.R b/inst/examples/proj4Leaflet.R index 7c8150870..57e1f4f4e 100644 --- a/inst/examples/proj4Leaflet.R +++ b/inst/examples/proj4Leaflet.R @@ -6,11 +6,11 @@ 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'))) %>% addProviderTiles(providers$OpenStreetMap) #'

Gothenberg, Sweeden in default projection leaflet() %>% - addTiles() %>% setView(11.965, 57.704, 16) + addProviderTiles(providers$OpenStreetMap) %>% setView(11.965, 57.704, 16) #'

Gothenberg, Sweeden in local projection diff --git a/inst/examples/simpleGraticule.R b/inst/examples/simpleGraticule.R index 31438f474..479eb0454 100644 --- a/inst/examples/simpleGraticule.R +++ b/inst/examples/simpleGraticule.R @@ -1,6 +1,6 @@ library(leaflet) # Default -l <- leaflet() %>% addTiles() %>% setView(0,0,1) +l <- leaflet() %>% addProviderTiles(providers$OpenStreetMap) %>% setView(0,0,1) #' Default simple Graticule l %>% addSimpleGraticule() diff --git a/inst/examples/terminator.R b/inst/examples/terminator.R index c949b3be4..358f1acea 100644 --- a/inst/examples/terminator.R +++ b/inst/examples/terminator.R @@ -1,13 +1,13 @@ library(leaflet) # Default Resolution -leaflet() %>% addTiles() %>% addTerminator() +leaflet() %>% addProviderTiles(providers$OpenStreetMap) %>% addTerminator() # Custom Resolutions -leaflet() %>% addTiles() %>% addTerminator(resolution=1) -leaflet() %>% addTiles() %>% addTerminator(resolution=100) +leaflet() %>% addProviderTiles(providers$OpenStreetMap) %>% addTerminator(resolution=1) +leaflet() %>% addProviderTiles(providers$OpenStreetMap) %>% addTerminator(resolution=100) # Custom Resolution + Custom Date and on a toggleable Layer -leaflet() %>% addTiles() %>% +leaflet() %>% addProviderTiles(providers$OpenStreetMap) %>% addTerminator(resolution=10, time='2013-06-20T21:00:00Z', group="daylight") %>% diff --git a/inst/htmlwidgets/leaflet.js b/inst/htmlwidgets/leaflet.js index 1b71de8eb..a752c12ed 100644 --- a/inst/htmlwidgets/leaflet.js +++ b/inst/htmlwidgets/leaflet.js @@ -184,7 +184,9 @@ 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); + //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; diff --git a/inst/htmlwidgets/lib/leaflet/images/1px.png b/inst/htmlwidgets/lib/leaflet/images/1px.png new file mode 100644 index 0000000000000000000000000000000000000000..9da19eacad3b03bb08bbddbbf4ac48dd78b3d838 GIT binary patch literal 68 zcmeAS@N?(olHy`uVBq!ia0vp^j3CUx0wlM}@Gt=>Zci7-kcv6Uzs@r-FtIZ-&5|)J Q1PU{Fy85}Sb4q9e0B4a5jsO4v literal 0 HcmV?d00001 diff --git a/javascript/src/crs_utils.js b/javascript/src/crs_utils.js index 988df4116..e25a933f7 100644 --- a/javascript/src/crs_utils.js +++ b/javascript/src/crs_utils.js @@ -47,8 +47,10 @@ export function getCRS(crsOptions) { crsOptions.options.transformation[3] ); } - crs = new Proj4Leaflet.CRS.TMS(crsOptions.code, crsOptions.proj4def, - crsOptions.projectedBounds, crsOptions.options); + //crs = new Proj4Leaflet.CRS.TMS(crsOptions.code, crsOptions.proj4def, + //crsOptions.projectedBounds, crsOptions.options); + crs = new Proj4Leaflet.CRS(crsOptions.code, crsOptions.proj4def, + crsOptions.options); break; } return crs; diff --git a/man/addLegend.Rd b/man/addLegend.Rd index 78ed9a9ce..ccaa27f54 100644 --- a/man/addLegend.Rd +++ b/man/addLegend.Rd @@ -103,7 +103,7 @@ factor palette, and a function to return labels of the form \samp{x[i] - x[i # !formatR library(leaflet) # a manual legend -leaflet() \%>\% addTiles() \%>\% addLegend( +leaflet() \%>\% addProviderTiles(providers$OpenStreetMap) \%>\% addLegend( position = 'bottomright', colors = rgb(t(col2rgb(palette())) / 255), labels = palette(), opacity = 1, diff --git a/man/map-options.Rd b/man/map-options.Rd index b7f539fe6..66b64af6b 100644 --- a/man/map-options.Rd +++ b/man/map-options.Rd @@ -65,7 +65,7 @@ transparency} \item{clickable}{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{noHide, direction, offset, textsize, textOnly, style, interactive, 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.html#marker}} From 51045259523ffddf3c80cb1e3123d07ec47c3466 Mon Sep 17 00:00:00 2001 From: Bhaskar Karambelkar Date: Fri, 10 Nov 2017 11:17:05 -0500 Subject: [PATCH 24/29] Fixed All issues with Proj4Leaflet support (I think!) --- NAMESPACE | 2 + R/layers.R | 56 +++++----- R/methods.R | 43 +++++++- inst/examples/awesomeMarkers.R | 4 +- inst/examples/easyButton.R | 4 +- inst/examples/geojson.R | 2 +- inst/examples/leaflet-measure.R | 2 +- inst/examples/legend.R | 2 +- inst/examples/marker-clustering.R | 4 +- inst/examples/minimap.R | 4 +- ...ions.R => proj4Leaflet-PolarProjections.R} | 0 inst/examples/proj4Leaflet-TMS.R | 84 +++++++++++++++ inst/examples/proj4Leaflet.R | 12 ++- inst/examples/proj4leaflet_with_tms.R | 102 ------------------ inst/examples/simpleGraticule.R | 2 +- inst/examples/terminator.R | 8 +- inst/htmlwidgets/leaflet.js | 20 +++- javascript/src/index.js | 8 ++ javascript/src/methods.js | 15 ++- man/addLegend.Rd | 2 +- man/map-methods.Rd | 12 ++- 21 files changed, 230 insertions(+), 158 deletions(-) rename inst/examples/{polarProjections.R => proj4Leaflet-PolarProjections.R} (100%) create mode 100644 inst/examples/proj4Leaflet-TMS.R delete mode 100644 inst/examples/proj4leaflet_with_tms.R diff --git a/NAMESPACE b/NAMESPACE index 1c15813e9..a5932e938 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -107,6 +107,8 @@ export(expandLimits) export(expandLimitsBbox) export(filterNULL) export(fitBounds) +export(flyTo) +export(flyToBounds) export(getMapData) export(groupOptions) export(hideGroup) diff --git a/R/layers.R b/R/layers.R index e7d52463e..d0787e4e4 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) ) @@ -323,7 +325,7 @@ tileOptions <- function( reuseTiles = FALSE, ... ) { - list( + filterNULL(list( minZoom = minZoom, maxZoom = maxZoom, maxNativeZoom = maxNativeZoom, tileSize = tileSize, subdomains = subdomains, errorTileUrl = errorTileUrl, tms = tms, continuousWorld = continuousWorld, noWrap = noWrap, @@ -332,7 +334,7 @@ tileOptions <- function( updateWhenIdle = updateWhenIdle, detectRetina = detectRetina, reuseTiles = reuseTiles, ... - ) + )) } #' Remove elements from a map @@ -400,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 @@ -461,11 +463,11 @@ popupOptions <- function( className = "", ... ) { - list( + filterNULL(list( maxWidth = maxWidth, minWidth = minWidth, maxHeight = maxHeight, autoPan = autoPan, keepInView = keepInView, closeButton = closeButton, zoomAnimation = zoomAnimation, closeOnClick = closeOnClick, className = className, ... - ) + )) } #' @rdname remove @@ -531,12 +533,12 @@ labelOptions <- function( # 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 @@ -825,11 +827,11 @@ markerOptions <- function( riseOffset = 250, ... ) { - list( + filterNULL(list( clickable = clickable, 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 @@ -852,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 @@ -898,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") @@ -963,10 +965,10 @@ pathOptions <- function( className = "", ... ) { - list( + filterNULL(list( lineCap = lineCap, lineJoin = lineJoin, clickable = clickable, pointerEvents = pointerEvents, className = className, ... - ) + )) } #' Options to highlight shapes (polylines/polygons/circles/rectangles) @@ -1020,11 +1022,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, @@ -1058,11 +1060,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) %>% @@ -1093,11 +1095,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) @@ -1132,11 +1134,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) @@ -1170,11 +1172,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) } @@ -1240,7 +1242,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/methods.R b/R/methods.R index ac2e43169..6c4bb4805 100644 --- a/R/methods.R +++ b/R/methods.R @@ -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/inst/examples/awesomeMarkers.R b/inst/examples/awesomeMarkers.R index c26a02ec8..cb72a23b2 100644 --- a/inst/examples/awesomeMarkers.R +++ b/inst/examples/awesomeMarkers.R @@ -51,7 +51,7 @@ library(dplyr) cities <- cities %>% mutate(PopCat=ifelse(Pop <500000,'blue','red')) -leaflet(cities) %>% addProviderTiles(providers$OpenStreetMap) %>% +leaflet(cities) %>% addTiles() %>% addAwesomeMarkers(lng = ~Long, lat = ~Lat, label = ~City, icon = icon.ion) @@ -61,7 +61,7 @@ icon.pop <- awesomeIcons(icon = 'users', library = 'fa', iconColor = 'black') -leaflet(cities) %>% addProviderTiles(providers$OpenStreetMap) %>% +leaflet(cities) %>% addTiles() %>% addAwesomeMarkers(lng = ~Long, lat = ~Lat, label = ~City, icon = icon.pop) diff --git a/inst/examples/easyButton.R b/inst/examples/easyButton.R index db48c9a52..91a97de1e 100644 --- a/inst/examples/easyButton.R +++ b/inst/examples/easyButton.R @@ -3,7 +3,7 @@ library(leaflet) #' Add two easy buttons. #' first to set zoom level to 1, #' second to find your self -leaflet() %>% addProviderTiles(providers$OpenStreetMap) %>% +leaflet() %>% addTiles() %>% addEasyButton(easyButton( icon='fa-globe', title='Zoom to Level 1', onClick=JS("function(btn, map){ map.setZoom(1);}"))) %>% @@ -12,7 +12,7 @@ leaflet() %>% addProviderTiles(providers$OpenStreetMap) %>% onClick=JS("function(btn, map){ map.locate({setView: true});}"))) #'

Toggle Button to freeze/unfreeze clustering at a zoom level. -leaflet() %>% addProviderTiles(providers$OpenStreetMap) %>% +leaflet() %>% addTiles() %>% addMarkers(data=quakes, clusterOptions = markerClusterOptions(), clusterId = 'quakesCluster') %>% diff --git a/inst/examples/geojson.R b/inst/examples/geojson.R index 5d92e96c2..6f48f1148 100644 --- a/inst/examples/geojson.R +++ b/inst/examples/geojson.R @@ -19,7 +19,7 @@ icons <- awesomeIconList( restaurant = makeAwesomeIcon(icon='cutlery', library='fa', markerColor = 'blue') ) -leaflet() %>% addProviderTiles(providers$OpenStreetMap) %>% +leaflet() %>% addTiles() %>% setView(10.758276373601069, 59.92448055859924, 13) %>% addAwesomeMarkers(data=spdf, label=~stringr::str_c(amenity,': ', name), diff --git a/inst/examples/leaflet-measure.R b/inst/examples/leaflet-measure.R index adf90af65..2799c7d99 100644 --- a/inst/examples/leaflet-measure.R +++ b/inst/examples/leaflet-measure.R @@ -1,7 +1,7 @@ library(leaflet) leaf <- leaflet() %>% - addProviderTiles(providers$OpenStreetMap) + addTiles() #'
#' Default Behavior diff --git a/inst/examples/legend.R b/inst/examples/legend.R index f42fb2631..0309eb309 100644 --- a/inst/examples/legend.R +++ b/inst/examples/legend.R @@ -1,7 +1,7 @@ # !formatR library(leaflet) # a manual legend -leaflet() %>% addProviderTiles(providers$OpenStreetMap) %>% addLegend( +leaflet() %>% addTiles() %>% addLegend( position = 'bottomright', colors = rgb(t(col2rgb(palette())) / 255), labels = palette(), opacity = 1, diff --git a/inst/examples/marker-clustering.R b/inst/examples/marker-clustering.R index fdb7a6afc..944471aa5 100644 --- a/inst/examples/marker-clustering.R +++ b/inst/examples/marker-clustering.R @@ -5,7 +5,7 @@ quakes <- quakes %>% dplyr::mutate(mag.level = cut(mag,c(3,4,5,6), labels = c('>3 & <=4', '>4 & <=5', '>5 & <=6'))) -l <- leaflet() %>% addProviderTiles(providers$OpenStreetMap) +l <- leaflet() %>% addTiles() #'

#' Default Clustering @@ -52,7 +52,7 @@ l2 %>% #'

#' Clustering with custom iconCreateFunction -leaflet(quakes) %>% addProviderTiles(providers$OpenStreetMap) %>% +leaflet(quakes) %>% addTiles() %>% addMarkers(clusterOptions = markerClusterOptions(iconCreateFunction = JS(" diff --git a/inst/examples/minimap.R b/inst/examples/minimap.R index 6542e12fe..241ca753f 100644 --- a/inst/examples/minimap.R +++ b/inst/examples/minimap.R @@ -3,7 +3,7 @@ library(leaflet) l <- leaflet() %>% setView(0,0,3) #' Default Minimap -l %>% addProviderTiles(providers$OpenStreetMap) %>% addMiniMap() +l %>% addTiles() %>% addMiniMap() #'
#' Different basemap for the minimap and togglable @@ -62,7 +62,7 @@ icons <- awesomeIconList( restaurant = makeAwesomeIcon(icon='cutlery', library='fa', markerColor = 'blue') ) -leaflet() %>% addProviderTiles(providers$OpenStreetMap) %>% +leaflet() %>% addTiles() %>% setView(10.758276373601069, 59.92448055859924, 13) %>% addAwesomeMarkers(data=spdf, label=~stringr::str_c(amenity,': ', name), diff --git a/inst/examples/polarProjections.R b/inst/examples/proj4Leaflet-PolarProjections.R similarity index 100% rename from inst/examples/polarProjections.R rename to inst/examples/proj4Leaflet-PolarProjections.R 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 57e1f4f4e..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'))) %>% addProviderTiles(providers$OpenStreetMap) + leafletOptions(crs=leafletCRS(crsClass='L.CRS.EPSG3857'))) %>% + addTiles() #'

Gothenberg, Sweeden in default projection leaflet() %>% - addProviderTiles(providers$OpenStreetMap) %>% 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/simpleGraticule.R b/inst/examples/simpleGraticule.R index 479eb0454..31438f474 100644 --- a/inst/examples/simpleGraticule.R +++ b/inst/examples/simpleGraticule.R @@ -1,6 +1,6 @@ library(leaflet) # Default -l <- leaflet() %>% addProviderTiles(providers$OpenStreetMap) %>% setView(0,0,1) +l <- leaflet() %>% addTiles() %>% setView(0,0,1) #' Default simple Graticule l %>% addSimpleGraticule() diff --git a/inst/examples/terminator.R b/inst/examples/terminator.R index 358f1acea..c949b3be4 100644 --- a/inst/examples/terminator.R +++ b/inst/examples/terminator.R @@ -1,13 +1,13 @@ library(leaflet) # Default Resolution -leaflet() %>% addProviderTiles(providers$OpenStreetMap) %>% addTerminator() +leaflet() %>% addTiles() %>% addTerminator() # Custom Resolutions -leaflet() %>% addProviderTiles(providers$OpenStreetMap) %>% addTerminator(resolution=1) -leaflet() %>% addProviderTiles(providers$OpenStreetMap) %>% addTerminator(resolution=100) +leaflet() %>% addTiles() %>% addTerminator(resolution=1) +leaflet() %>% addTiles() %>% addTerminator(resolution=100) # Custom Resolution + Custom Date and on a toggleable Layer -leaflet() %>% addProviderTiles(providers$OpenStreetMap) %>% +leaflet() %>% addTiles() %>% addTerminator(resolution=10, time='2013-06-20T21:00:00Z', group="daylight") %>% diff --git a/inst/htmlwidgets/leaflet.js b/inst/htmlwidgets/leaflet.js index a752c12ed..2f9423b0d 100644 --- a/inst/htmlwidgets/leaflet.js +++ b/inst/htmlwidgets/leaflet.js @@ -635,6 +635,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; } @@ -1210,8 +1218,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) { diff --git a/javascript/src/index.js b/javascript/src/index.js index 8934db4c0..6baa86705 100644 --- a/javascript/src/index.js +++ b/javascript/src/index.js @@ -202,6 +202,14 @@ HTMLWidgets.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; } diff --git a/javascript/src/methods.js b/javascript/src/methods.js index 9476aea13..43bdaa3ee 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] diff --git a/man/addLegend.Rd b/man/addLegend.Rd index ccaa27f54..78ed9a9ce 100644 --- a/man/addLegend.Rd +++ b/man/addLegend.Rd @@ -103,7 +103,7 @@ factor palette, and a function to return labels of the form \samp{x[i] - x[i # !formatR library(leaflet) # a manual legend -leaflet() \%>\% addProviderTiles(providers$OpenStreetMap) \%>\% addLegend( +leaflet() \%>\% addTiles() \%>\% addLegend( position = 'bottomright', colors = rgb(t(col2rgb(palette())) / 255), labels = palette(), opacity = 1, diff --git a/man/map-methods.Rd b/man/map-methods.Rd index 5c05c846b..04d01a145 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) @@ -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 From e35b66113baeafb787ece277202f44829c4cca27 Mon Sep 17 00:00:00 2001 From: Bhaskar Karambelkar Date: Sun, 12 Nov 2017 21:14:16 -0500 Subject: [PATCH 25/29] Latest Providers --- data-raw/providerNames.R | 2 + data/providers.details.rda | Bin 4294 -> 4716 bytes data/providers.rda | Bin 1396 -> 1575 bytes .../leaflet-providers/leaflet-providers.js | 64 +- .../lib/leaflet-providers/providers.json | 1051 +++++++++-------- 5 files changed, 594 insertions(+), 523 deletions(-) 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 7e6cf596087439f3edb2763a7cf67db4b54e89a5..66d6d59d25efe095a170cfaa29ca980480774d39 100644 GIT binary patch literal 4716 zcmV-y5|iyhT4*^jL0KkKSzL%4Y5*CofB*mg|9#>A|NsC0|M$QD|Nn*#{5&)WqJThF z0%1j66dT|Ze-FE^1L@wtAlRt_yJ!Q}iB5n30B8U-)_?&(4?q{8p%9rF8f7p5YH5mX zQ_-3cg)(NO98K?jN00D>q(7V&tZRz=Q zc`jD$KJWSlt%wSSBm+RiCWI9;F#y;A4Wxu-xHgI^f`}@TO#{Zj0)nt}03-lFNg)i8 zR)Ld9(J@h4h6o*10zinkYC#}KktHQ02uXw}5jo5fQjjEx%$lh=NKPi~tH+o@Rt!}tF-W|Cnaxr$*U1|+#}b9W4lw}{Vj=)pF-SOGWCCc&gkbIYYlE!*l8@|R^Ds4w_$~9S5?G1bm9G|!c?V|nsmZuKVZc(O5tKGbC%4k=`-j=F2nS#j<3HF1J0VnW!`Rwh26hQTp3 zm<=W^IV1#UCpn~-D9{}Z320Z1jL86li*X1}2geeWYU703DB@&FDAYFSoK3k&!~}`L zWtHCf(y z2*NWEN|Q1%1^$&G4OL1LBP9*A*gK<2Sx}G-0FwcrPefMlG^!ABd6~P{Vf8FXxX_*# zyuQ?J?Y`}$z!*B(UoW{95;grxaEQ;wOKPm7qtGlIexi&Y1W-|p4;6e|%B01zb_ zD5OAwU~G0+3hGtWoN3=CR3J-&mO{z9;^%tH-M?Zj6riIEt%4^M?!}jSGPSm0mN8*4b#?!7WYfrWOG+L;bwgVUa=sa0Jo ztqI&Dx5PBqF)s`Tnb4M&H4WoOl30W)O$4S*eJ5>l@ae*B9)x!!770s=H>(j%EF~`8 zw&tyQEW)%#eIsiL7ShUCP45wG3>z$Llta|?^|s3?;fUU}%FFle$(ucvW@fv%B|iTB z((%)w=)x1O{8!SXnjRIFR>`>QJ_b#ba&3ziS(*h#s^$5XbL*t+g61IyWD*iv=ml6I z1z->q^ALgnS(9X4_@ywah?&K zm$X^ljO3#Ga^>#IqT`J>T?0!?tA@ETGRujm4cXTmE7HhRcA5wZ*ZnzZ4Z z@w42zLO4|f5WgyB0s2-93r01JhInz93FHa0K6 z+ktNu?tJ5Z??_4aph>< zakV9@ad2{BXm)Y&n2`N&MeBns%@o|)9_QQKz4dvIhl-J_T>V-cqhn%h7rrD^@H_i| z14p|G4(hzmvn;ib!J3YBdVYTnEFNMHK}cNDEg{k@{n{=8bjWNr>v-G_HcR-Yk}3x; z-^sf4vlQ>3UdH%sDro0A?*@^G5K-onL9JkYz95HDc>eXK)+bC53f)PQLqTYamp(*l zcJ0#_kwCDgae98n#G8_z@%5h@^yHXQ(4$c>O`JDn4FPWzpy>{XZneU^%~|Z0A&?|5vI~wPuqHTw%^bjm25!MT zn_+0c3Jy@Q6i7U1zY_aS5S>VByk8RojgOx`SeA96lVSUd$ZKw^e0rjea!b@AgO~y_CgFyX`?DG23-shM~WGut5!Z98cGCQTp|a0Q=#L#1O7~? zp;(r?37eh6MxMmGUnnU0z!b6o$bopj<^)+4c@eBoMb$CT$+*hnBf2NL6&XuK1QYh^ zWA;`gR{%0x?X-WVODj)#Ah?K3B4h`*6p_dzdx40+u%;gKI;&84hB5}(jrJ#hyR{^s z1kq}W!RL=;3-m!52uIJs1Z+rH&M-}d68r>5!@y-~fT4j5By*I%xUJlY;2jtG^+xc^ z9u6(5wBgvn?#6O9j%>is3M~T!AT%bJtU-lf6i|i;h6Na5^a*Ji!N_#^xH(@eUt;&| z*-Is4okd{NLc3=M@O@+;I-TEo=u%os7oJ>i6DO|wp5ut+K*6TdYXL728y%%}qEIAgmx|Bz;W26QJ%O zq3>_}y!LhUzE$P`#Izdn3343^x1hV)_Bd|spvRQae|%ma>-shn09Eb-H_0I6ZLYg# zm&sDl?JDz)gS8GO{sKu)%?43%n*C!W23jF%Ti!j(>$G5V+9Nr6z28DL=EiD80^50q zc9FeNj1V@96hd&%QHM;MCYVD+G8p>fzn_QM=n~&r5sB6y&XR)jfPzZM%vx%LJ*bEa zCt4qiVG&0K7P%L0M4U(nT#KRD9){fk}-v zIHn154YM$^U%p1fjcgl5MnfL_a>yziO&Eq%ZN~5-a)gbQiFoOj&K?udxp8@6LA?Yr zQEk|DH*Ac-#&wYk4w)UfP(SngxltUrI?yf*EDw3c{< z0}Q~^#e#>^h4Q7m)_lu1xLQo46B$kmByzbq)IyqJ3P}l z*h4Ki5e9Yaa(e#B2T1P@MT==|%Mk{IKa`R7JzuXQ(B>ZLr+smtx>8CyfQRE05D;6yF`K%ki@eP0pnk)&o8wp^>oL`edWvNRZsP%u;< zTcXkq*D=&OyZP)Z>vn8hOF5uu3q`5saMDLh<>{QR&Q&3M_L~d?G3|FY?J|~|nDfMA zE7V!)=bprM4O_$awZ&U(FKJ$~-)bnp_|(mDs}xkU_%L zwo*ft3C%!dAIROJ>U7}2mg>5dUdzPDkwK}61{{J~Gf>qKm7$T7>=o+Xf!Y}o?ins~ zcvCIwQE6s34gnW2xeX#si7d3CG?*coDMr1SYG!COWS|hq1kw{pmBR4AoopD{2J>x@ zm!dR4NZS{tB4IfsnQ7dw5M4+>H&PhjEG-#oBt(Z%31rJ}sPlrwv1m2I7Pwtx^m*L{ zYiqrP-n!FXKBBrVX<0E#00eGeF)=7~|VlwX?qt)IhU*BV`sU$m8%SHn_63$30R&NLk8EZ*Fd_xmV zk#j>wg!#r!$yAbBOfkc|>3y&TpvZax?g;EQ+u+~UR5gWyNn{c-*o?bRNH74m%7CB> zVqP>K4W-8ouZTDLBg&bq)yQee7=**qOT@}cCxsn>O;f+fX)^F$wiy`_lHv8knSwhF z3rj*;08@mGqfv+vAv307Uq;F;X}x|gJH6fei_;LYjeuWt)#1~j*CZ_sXv;1B&}iv- z5rRpcSXY>f0Eik!p7%6%$xR#LLq$-8G%i@}6L8Kq3{ZxMV(Ja^K_&+vDvvWklG46H zy$!bCRKD^LHAk;-vl1UPl#*v)-P#^=E|KN{I?F-iytd)ZcHd`8(wNH(!9Z*iu7wMU z0%(kY(12hHlGa?qszE}cE)c3%feac*ay&<8o_f`)%abPompachkwiY5#zY~RmQ^uH zG;owvBof$MlK{&WiJQR@62dTwsF5WWqOy_|9Cj;P89;|7)>smW(ZyK}lad2uTPrB- z%QF17kF#wHORSJXCh#2+L=OAKfn^A^;p%*T8kW=-u=?ZBapsVZV45d4*m6FVTfK>D zW_0owSR4yiVDg!j#R6|a@>(AH1$bhvAVzb|nU$9hj2OtdBe`g6#Vo-k#h?SRJy+hW z*#Kl4c2)@vZWx9QB|9k=LL!kVlOgJ+T5n!brD<#uD3DtnA2ue!fU2eE7M@`AtI_K7 znTa62!oml|9P&dT$h4e0{?D-Ze9dantgUGb0v92`OE7Mh-hAbNQVypk9a_8v5q`-V@2-yEOQ~Sy+-(?bM7OQlKTg0*a|dkzn1X zEsKAwU{rwxM5fm>w{ULbv#jkxcr&_u+mhk zTwutsF-zT$qz_t1G#ITS6oL&qfQbYS6O$pQs!fn_sz{kXPAU>@oTDXQIS8k_L{y|r zwh}s>RvgDPrRduR#6mDGnZ<#iLc=DMW*o#X!bU6inyu0Ge)rzo90kw#8PBc2hs6R4 zFcWAKXcynW{X=MZ{(pq);{q}4>Zlx7^Uz7=JR>b1=2lb`PtsYM1Tl> ugo>r62MnBY$s`~(y1&$_$TFPewqVQJ@Bz13{n-5Sjo@Od2Hg)M<(6(3oj7 z4G%~FGHCSx13*1PL8d@x00000Xn~U;VhuFY0$~|2hKvAB8eszv!eTT5k)eSyFia+z zG|Y6&Nv4^prVzvonlucJ27!@;z!M_`(?Nt}V3{!(jTjX~ zX{JU2GBBEA4F({<6DA3hKxAPsfB-QJ07DU=02*X%MnI7unjivbXiQBF8UUIxCYh5= zl-e?yJwrokH1a@bXlMY?&>90KfB?yUqmpV`Pr3e~mr4SmVgaF~h6pNP#FJozn-GHw z!%(U!3aJ3Z^jruoS4~xo!Lc66bhz)d%^am}1 zAhRM32dc?bs_^WmYMDjER5Fle+{u;Z#gRgUxFde;MID1NVc+b?%rYD$qVe3Ei|_Y%8~+xqE!YFAB&ZRMn3^;+XpM1tc9-c$(! zh8_r@-l_e_mPm(k6QWftoFU3$b22_#oSNC@ODzg7F>zP_=etyW_uQ z$grga7+%LHpKdE|w2iG1@qKMyPxk6BrI$d=Cz?acIRwn)vtsO0p>kvn7*|BJG91MO zj~ta1qaDFJAuV7rux*0*aH%>*P=@d^9w1_zkrJx``bRb72V=irA^_i!8aj|_Q5ysi zB`kGoA3kA}u6EkKMbx^N6WlDu4VO0L;Og$k(tNnw)p3!R#^caJ%P<(QZgN#~F|^fU znZ)V{*D(vhU=m$gU^5CdTAXZ~Cgj@|HeH$pMpet|UCFMKx(nEnU2!2HZy_Xv*d!(( z0Uu?gfi6}F34Ow91ccH+4G2g$m=Tq}Z>WF2Bak2yHD(3~>njyKDeD4BKm;i1FQMn1D zQNyil#q18^C_}G6X>p2=g0NV%1_ou7oHpTL*9`ce#(HBpLrRH3o9u^*brMcpfs`E_ zH;p(1q%_>`VR#rtZwi#W88R0lceS?e@ceE}A?>UxldUos z1UA|<9|Oz&mz498UB$zC=2Km4fDW0i6%hu8cMoQ|yWN1=NoO4h;)KXTcqJ&HkJg@r zVe#-pyJ0fHxE;;krtGFOMq;FN&H&~s=+OlsosH8eQh<+#Z$a9+Q?HxA@etJ(-aW{} zHye{qc%GH$XWn&hCTmo9D@beils@~bsgUoLpj}^_a^#Kwdl0m@)-49+&c^?SR7=g> z&1?V%1F_4`07N9B)6Wk2c!k*q|gR{=+J>Gky7%=Wn81=1WQHVjB9D$ZE zce0jfCpN(eZfvmim*;2AtwExDc&p@cGL}2md6?M)WP*pPFv zv>a@ONh;c^V=|T$5KrBykMm4qR}dL5cChDKPT}^F1`#q3L{di*LFo)b1DR+KU}Hn0 zKG*L3Ov0bfI8T%04=(VUGM~-s3DZo^X^F6+Uiv;A^CMFPHWDxGD(;1_3x8!ajH?}J z>Uz4EJ?tRXIWsFUSPVb`={{*uwl>-Z#?l%D!Lg>F_KeUvkB^43Uw@ld7W}xSR9rN{ zU$b$1U;)Y7_$>-cLES8CBx=6TfZA~&VAE-}fQPk5PT?8X&nKCIi>gbt`I-ZdaQ!@R zVhR#BSGFX#&>VScRY9Y0k`QRl%}qEIAgmx|C6ncyeuNV~ZtuOCI+`DWbO6M&nz4y= z9gO9@&ue@CrmA7LI^tt0cCz*D~_^Ten_ymgTxa!48k#CW-V6)8jJ0W4$9n z)$DCwBSr@`k}o!R5?b=ef?-g zGb&4i5xzksbY?7RgFTTD7f!#2add_0maX2BT~i)@wb(X>;gJo&6F>8i-#U>Pq8EB( z1}2YZF683eH{0sKqW68AuWpu-zc@L(9`vpi+1?kRy0(-;fRZAH27)f`pu2t9-v%qW z4~~k1+ri;IQpd&N(LIz88JL4vtBH_Za8Nc4A#j68DeV+neug>}t2W{(j7l}7zM9NS zbl(iv^ydLdbncP9G%9g@0BmM$!!f%lUz~7>7q~{kWX#Y=GX|5D7AR2ZmDCDsX|csI z2T3z9vSZ#OV70W`DmY`_jyV+$28>~pwfK#}1t$nLN1AopwDqwIQw&#M&9`1q>Vrrv z(~gO7og;F^PKt+kM!hQ;jJH}l3&=lz;Jh{Jfw3&n1Pn5RPa6>rjx}V-?-CV9zzC-u z~gGi zLrocBDCXz#bLYY|!e5j^0HY9KQoj%&5PHop88dj6uFm#@MhffF>KKqE z!8k}ubUZuO7i7`8Rhusiy0by1s^MHmYbhGTDE4DwI%ciG__ak_Y%J2svSXG_`UP&rB#N}ShJxmO5j3~JSZTQ! zra`?WYpEg1QdAAm`gk|*rz9AeYfg*hJVrE%4NMSW!XrG*Eh~c)msF=>@E(B3mu$&< zo1RDMDyws^DcOTZT4klWc^%;|K{b zAR_dWF7od7Li$2Ux{${O#fu_DqP`+(CoiLW|K!q&yd6u4LiMo`Rj0+i#fVyo0u*%aB>g9CA<$>l__{=Q8OYWQEsAJr|c)dRIfxv?em9 zP?$C$=Qsfnh{g;68UasHW*o%Jkx>>BELj2=G?63QIsLk7SF4np>M|GH8>?4a)0tmD zo6+d7eFO^w8omT)GECZEWEBlKC6FX<<^a#srT2x};4zK5vI#^qCJiMj-4{U=iA;vjNf*>*+tJ4+L7?w?eYd^Qtz&CAUJ!7R zw|jGwil9H>`3wYhz0A*UU=S)L<_eU4+mSpiFD|VsPjtiH5OF_*pwkTmjuZ_r3&!{1PxIZXMvuf-~X)04y1X3p92I=zqoBkxmpODrP?Zzyw>nJpcdz diff --git a/data/providers.rda b/data/providers.rda index 0d750ff2fd77c6abd111dc0a87ed15ae025adfcb..0f953ae90d61a43a1b49f4b7f10ba9f2832c6d08 100644 GIT binary patch literal 1575 zcmV+?2H5#RT4*^jL0KkKS=NSNvj7MFe}Mo0|NjU9d4NCv-OxY(-{AlOU{00tcY^-=*(QzoWpOe4_Vs00}>34j3x01h%_(V#SGh{({yFeZ&L z1|va)02mcQK!8So0%~kVf@C#3Q`E>aBT1&7niDl20MNt%j6eb;k_Rv#0OZH5$Sv)L zTA|G7@70MA%VYS)|6z<@$yB`>K)uY4FD0UEgIWQrrV-+)LOuVHiUldz%(Fy*MNHgo zmK3LunIO`JcpWOj50(WWd&E9F>bh8A(u71lp8kKAYypI=Fag^$F9$T=JhP@!B8n`8 z$q`VoQY)yc7gMNZBAu3l5e4QFgvhE)tYxJVg8GD3*eO&mAeBNzv=uX-G*c%|ili6N zVXi4ir9#*yK?1_YB2Cloh91Rxl7wods*?vJx#Ty=Kju z8YqZ}i9!((F){N@KpqJZ1NM=&Vj>|IN)ZvYyzeA*BaKTgQ&GOA;TRT1D7cImsd8G# zQHqvgh?AMfq^ZD_mL+8UwhQ{tlemE%5@sgGfMZx=|o`i_mqsh-%d{r*Ijbz ze5PhCbyZX_WzjPvL(+(b$DRIN4u{;AE8Mwb^?F*JX?|hC+Ov^qN@jnC$KKZPHxf#n zN_*dvt!G<-ip}@p$%}FCnVZ-t;(ianx$zDceRKXa9SsUoB|Q&A%FoU8Y_B5fy6U;Q zvE*hyoZVRU&KfSu$97p?j#GYDWtG+}NR$+V@=JhedQq*6%#$-K5rdJ?|F46Q=uz!t z)3RquQClW_P9x04b@MdtX?z_nrOu~?)cKZ6;PJc;6ZC0uH9TobTaKiM#Q6J>5V3dF zGe__5nTU>X=Y3_)W=@t*8eOgz)b%_MLD1=QxRz?yGYH)qcFf8icH`DYH8UOeL!G$R zvEN`CvYGN0IFeliT{B4YB@W+bLh;-@=_%escZ<*TXE1(geR7#fPeRCzX%w^0BVzx= z)|Lri!J(yDJBUN=MunTpu+-| zX(P3*(7ydORZ3Et3*6q#6G_5TL#P>CM1*R_j|j+Y8B~fX3B;wCQZNAq$AL~EAG;%g zsHVh*`K8oLnGv);*6@tPBkXQ|om#Wqb=O^FQXFC|VwS+n#hnGk->Y*rHBv(3KvEJ& zxkOmGnC3=XMJ)dgB`V1RHRT*XHL3RK@{C> za-$>{j{F7`R(m89&=%A&6ksg|C^{5RLW>6K1>RHnP@~ z*$}0Yw9MIRnTb%9ib4{z+luv?Qz`J4STrR@D2vK!dmgu`{Sxw<1a}z>>2#p$G#g$+ z=R!GL?q*7G?@Yv;s&^5Cl||_}j^OMJkq))Z=IOxfMn&dxzT9hKyG9c-!NLg8N*#<; zlaPdVuWfR-%owjSJ@!ME>FScErXfin*hcD5x!B_uyl zvyjw`RDB4A=+Z+nn^6lHj-=(L%UaZkvY05mFR7mskVY$x`!bNTCjup)%+RojZD2yi z!sJDp7_^0q=*0<3CPq$2GRA z(?FVJ%`^z|Xq!?X2QUD}1OO!z378Nf=jYpLV)%ojs&9Djco6Nxjy{fM6qyb|7D(cd z!JH6mS@QwH6u%HI{h4zWOAtgJu)7PX51k+mM4iDoM?sD$BS{1aN-6QZwc1Ifg1`W< zT$+E>77}Ai)C8U?@l&4d70+6!dhM>-<*X~VyK5?0R=S*FC1oN;G0gQDHfE9 z5K5H=E2`GfEh)^rv3X<0l0>3O4;2KKRP4Q>B2Vg*f}}|pQW9`FoFl0@R$YS4X9~^Y zVqG#!35z9|DX@zfEW0F~PGX8AqKU2eKNj|vBiQ_!!(-kX3GHO+e{PhX;Ns${(#>bg z`yX1Kl{yA2TN|IPSBdmK*Rkz=4`S{1>yDMI*m@e89|x@_FPE)k&(Z45-G&%o!q1IW zOW|u;(ThH+sw962BWu$CZl_b&r#srgbNPKOZwj8^<8UtKUX-e>k84}T+My#-E*>{*~dedVnsw%3NCN4Ka-1oijon!K5)wZirlG|##oQKTGhKj2@ znx6N{>tOD9UI&Fwd(QGW&*7=a*7K=KZ#xtp1L5sS7clizSp7exNjgKN_Lw>uyX@X| zJZ?A6`d&w@>UZ5PMcVdNNZ%X$6;eGd=hRHCRXbfymh)ogYY^9+SIAuCQGl2%o`oaF z_Fz1t(xbkUzUw~&Nulmj?WIzbde=#@LeEH--G0U`ElUqGxYJ6gRVtzsN>Y)fP2p#i zp(otjeN|NwoC)>1-xlzk2DI9`oDI8_l~HveOkAfjPBfh9#!Y61mxZX!GHGXws+4Lh zqZJD|#v>)e980%J;W`Y1SArrSK!FD!DmF$|OT;DlQ9@7xjj61aAtpyyU`@rCxLO-t zMwcL;`I*GjS+z+xPQzQFCis3X@SBKFxxMi0*QX3H!waR6$|cN{+8DH?YI2&^69*%;b_CuH2Lt<7%BW5>-ce-X=s4Y^__$sn_l}g5 zZtOFU&L?7K&}ll`TNyCj z#;TaO(GAjxiOPiVFmJh?<0c1y{dwoHi+lSQh$E>SLc8;d4R6sGZ|VJSw%l4@*dX-RW5$e9^A zRyBnha;lWfbvj#(OrmdHyGv54scKr4QaDPrRVu2Zxv1P&S#>;*{x0N-aG@c!pwa+? Cwv%!I diff --git a/inst/htmlwidgets/lib/leaflet-providers/leaflet-providers.js b/inst/htmlwidgets/lib/leaflet-providers/leaflet-providers.js index a29e04d25..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,41 +105,48 @@ } }, DE: { - url: '//{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?apikey={apikey}', + url: 'https://{s}.tile.thunderforest.com/{variant}/{z}/{x}/{y}.png?apikey={apikey}', options: { attribution: '© Thunderforest, {attribution.OpenStreetMap}', @@ -175,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', @@ -198,7 +200,7 @@ } }, 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', @@ -211,7 +213,7 @@ } }, 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 — ' + @@ -222,7 +224,7 @@ } }, 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, ' + @@ -279,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' @@ -363,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: { @@ -394,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: { @@ -496,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', @@ -563,8 +566,25 @@ } } }, + 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 ' + @@ -628,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]], 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" + } + } } From 6a3d207f0dc5d38f7ec50959be07f68ed67e3cf5 Mon Sep 17 00:00:00 2001 From: Bhaskar Karambelkar Date: Sun, 12 Nov 2017 21:38:33 -0500 Subject: [PATCH 26/29] Deprecated L.Proj.CRS.TMS --- R/leaflet.R | 29 +++++++++++++++++++++-------- javascript/src/crs_utils.js | 1 + man/leaflet.Rd | 9 ++++----- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/R/leaflet.R b/R/leaflet.R index 8841f6801..2fa5eb342 100644 --- a/R/leaflet.R +++ b/R/leaflet.R @@ -121,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, @@ -146,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) @@ -159,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( @@ -175,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/javascript/src/crs_utils.js b/javascript/src/crs_utils.js index e25a933f7..9190ab46f 100644 --- a/javascript/src/crs_utils.js +++ b/javascript/src/crs_utils.js @@ -47,6 +47,7 @@ export function getCRS(crsOptions) { crsOptions.options.transformation[3] ); } + // 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 Proj4Leaflet.CRS(crsOptions.code, crsOptions.proj4def, diff --git a/man/leaflet.Rd b/man/leaflet.Rd index 98f4df6b6..5a1f4e1e0 100644 --- a/man/leaflet.Rd +++ b/man/leaflet.Rd @@ -47,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.} @@ -69,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 @@ -264,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. } From 5fb50013edd9dd1bffce50c1af8aca8af0ab5253 Mon Sep 17 00:00:00 2001 From: Bhaskar Karambelkar Date: Mon, 13 Nov 2017 00:02:36 -0500 Subject: [PATCH 27/29] Fixed Arguments, but retained backward compatibility. Fixed links to Leaflet JS docs. Kept final pkg under 5MB --- .Rbuildignore | 9 +++++++ R/layers.R | 53 ++++++++++++++++++++------------------ R/methods.R | 4 +-- R/plugin-graticule.R | 2 +- R/plugin-measure.R | 4 +-- R/plugin-minimap.R | 4 +-- R/plugin-providers.R | 20 ++++++-------- R/scalebar.R | 2 +- man/addGraticule.Rd | 2 +- man/addLayersControl.Rd | 2 +- man/addMeasure.Rd | 4 +-- man/addMiniMap.Rd | 4 +-- man/addProviderTiles.Rd | 7 +++-- man/addScaleBar.Rd | 2 +- man/map-layers.Rd | 2 +- man/map-methods.Rd | 4 +-- man/map-options.Rd | 35 +++++++++++++------------ tests/testit/test-remote.R | 6 ++--- 18 files changed, 87 insertions(+), 79 deletions(-) diff --git a/.Rbuildignore b/.Rbuildignore index c0b6e459c..acd7babb9 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -15,3 +15,12 @@ ^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/R/layers.R b/R/layers.R index d0787e4e4..d9124db0d 100644 --- a/R/layers.R +++ b/R/layers.R @@ -147,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( @@ -299,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 @@ -313,7 +313,6 @@ tileOptions <- function( subdomains = 'abc', errorTileUrl = '', tms = FALSE, - continuousWorld = FALSE, noWrap = FALSE, zoomOffset = 0, zoomReverse = FALSE, @@ -322,17 +321,15 @@ tileOptions <- function( unloadInvisibleTiles = NULL, updateWhenIdle = NULL, detectRetina = FALSE, - reuseTiles = FALSE, ... ) { 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, ... )) } @@ -382,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) @@ -444,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( @@ -454,10 +454,6 @@ popupOptions <- function( autoPan = TRUE, keepInView = FALSE, closeButton = TRUE, - # offset = TODO, - # autoPanPaddingTopLeft = TODO, - # autoPanPaddingBottomRight = TODO, - # autoPanPadding = TODO, zoomAnimation = TRUE, closeOnClick = NULL, className = "", @@ -508,7 +504,7 @@ safeLabel <- function(label, data) { } #' @param -#' noHide,direction,offset,textsize,textOnly,style,interactive,permanent +#' 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 @@ -518,8 +514,7 @@ labelOptions <- function( noHide = NULL, permanent = FALSE, className = '', - direction = 'right', - #pane = NULL, + direction = 'auto', offset = c(0,0), opacity = 1, textsize = "10px", @@ -528,7 +523,7 @@ 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 @@ -645,7 +640,7 @@ markerClusterDependencies <- function() { 'leaflet-markercluster', '1.0.5', system.file('htmlwidgets/plugins/Leaflet.markercluster', package = 'leaflet'), - script = c('leaflet.markercluster.js', 'leaflet.markercluster.freezable-src.js', 'leaflet.markercluster.layersupport-src.js'), + script = c('leaflet.markercluster.js', 'leaflet.markercluster.freezable.js', 'leaflet.markercluster.layersupport.js'), stylesheet = c('MarkerCluster.css', 'MarkerCluster.Default.css') ) ) @@ -809,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 = "", @@ -827,8 +824,11 @@ markerOptions <- function( riseOffset = 250, ... ) { + # use old (Leaflet 0.7.x) clickable if provided + if(!is.null(clickable) && interactive != clickable) interactive <- clickable + filterNULL(list( - clickable = clickable, draggable = draggable, keyboard = keyboard, + interactive = interactive, draggable = draggable, keyboard = keyboard, title = title, alt = alt, zIndexOffset = zIndexOffset, opacity = opacity, riseOnHover = riseOnHover, riseOffset = riseOffset, ... )) @@ -841,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} @@ -960,13 +960,16 @@ removeMarkerFromCluster <- function(map, layerId, clusterId) { pathOptions <- function( lineCap = NULL, lineJoin = NULL, - clickable = TRUE, + clickable = NULL, + interactive = TRUE, pointerEvents = NULL, className = "", ... ) { + # use old (Leaflet 0.7.x) clickable if provided + if(!is.null(clickable) && interactive != clickable) interactive <- clickable filterNULL(list( - lineCap = lineCap, lineJoin = lineJoin, clickable = clickable, + lineCap = lineCap, lineJoin = lineJoin, interactive = interactive , pointerEvents = pointerEvents, className = className, ... )) } @@ -1195,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. #' diff --git a/R/methods.R b/R/methods.R index 6c4bb4805..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 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 171c30944..32ea7a0a6 100644 --- a/R/plugin-measure.R +++ b/R/plugin-measure.R @@ -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 d8499c6cf..c25812422 100644 --- a/R/plugin-providers.R +++ b/R/plugin-providers.R @@ -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/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/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/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 04d01a145..a6d8e837a 100644 --- a/man/map-methods.Rd +++ b/man/map-methods.Rd @@ -31,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} } @@ -66,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 66b64af6b..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, interactive, permanent}{label options; see \url{http://leafletjs.com/reference-1.2.0.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/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)) From 5baeada4daeae2da948542bb866fb0935905d354 Mon Sep 17 00:00:00 2001 From: Bhaskar Karambelkar Date: Mon, 13 Nov 2017 00:49:52 -0500 Subject: [PATCH 28/29] Fixes #456 --- inst/htmlwidgets/leaflet.js | 5 +++-- javascript/src/methods.js | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/inst/htmlwidgets/leaflet.js b/inst/htmlwidgets/leaflet.js index 2f9423b0d..0aa9333cc 100644 --- a/inst/htmlwidgets/leaflet.js +++ b/inst/htmlwidgets/leaflet.js @@ -184,6 +184,7 @@ 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]); } + // 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); @@ -1875,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/javascript/src/methods.js b/javascript/src/methods.js index 43bdaa3ee..ec4a27dc7 100644 --- a/javascript/src/methods.js +++ b/javascript/src/methods.js @@ -788,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); } From 279c44b8906e4d0b1daad27b61a45960f7872296 Mon Sep 17 00:00:00 2001 From: timelyportfolio Date: Mon, 20 Nov 2017 20:55:57 -0600 Subject: [PATCH 29/29] remove examples left from testing/experimentation --- inst/errors/errors.Rmd | 56 ----------- inst/examples/crosstalk.R | 34 ------- inst/examples/crosstalk_shiny.R | 65 ------------- inst/examples/draw_shiny_deleted.R | 30 ------ inst/examples/experiment_split.R | 113 ----------------------- inst/examples/gadget_draw.R | 45 --------- inst/examples/gadget_draw2.R | 95 ------------------- inst/examples/mapedit_attribute_poc.R | 42 --------- inst/examples/sf_leafletdraw_intersect.R | 52 ----------- 9 files changed, 532 deletions(-) delete mode 100644 inst/errors/errors.Rmd delete mode 100644 inst/examples/crosstalk.R delete mode 100644 inst/examples/crosstalk_shiny.R delete mode 100644 inst/examples/draw_shiny_deleted.R delete mode 100644 inst/examples/experiment_split.R delete mode 100644 inst/examples/gadget_draw.R delete mode 100644 inst/examples/gadget_draw2.R delete mode 100644 inst/examples/mapedit_attribute_poc.R delete mode 100644 inst/examples/sf_leafletdraw_intersect.R 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/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/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/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()