Skip to content
This repository has been archived by the owner on Sep 30, 2021. It is now read-only.

Commit

Permalink
merged v1x -> webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
schloerke committed Mar 21, 2018
2 parents 9235ab9 + cd18c4a commit 680cbef
Show file tree
Hide file tree
Showing 15 changed files with 252 additions and 246 deletions.
6 changes: 6 additions & 0 deletions .lintr
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
linters: with_defaults(
camel_case_linter = NULL, # 122
line_length_linter = NULL, # 33
commented_code_linter = NULL, # 3
NULL
)
44 changes: 22 additions & 22 deletions R/basemapLayers.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@
#' Taken from \url{https://esri.github.io/esri-leaflet/api-reference/layers/basemap-layer.html}.
#' @export
esriBasemapLayers <- list(
'Streets' = 'Streets',
'Topographic' = 'Topographic',
'NationalGeographic' = 'NationalGeographic',
'Oceans' = 'Oceans',
'Gray' = 'Gray',
'DarkGray' = 'DarkGray',
'Imagery' = 'Imagery',
'ShadedRelief' = 'ShadedRelief',
'Terrain' = 'Terrain')
"Streets" = "Streets",
"Topographic" = "Topographic",
"NationalGeographic" = "NationalGeographic",
"Oceans" = "Oceans",
"Gray" = "Gray",
"DarkGray" = "DarkGray",
"Imagery" = "Imagery",
"ShadedRelief" = "ShadedRelief",
"Terrain" = "Terrain")

#' Esri basemap labels.
#'
#' Taken from \url{https://esri.github.io/esri-leaflet/api-reference/layers/basemap-layer.html#optional-labels}.
#' @export
esriBasemapLabels <- list(
'OceansLabels' = 'OceansLabels',
'GrayLabels' = 'GrayLabels',
'DarkGrayLabels' = 'DarkGrayLabels',
'ImageryLabels' = 'ImageryLabels',
'ImageryTransportation' = 'ImageryTransportation',
'ShadedReliefLabels' = 'ShadedReliefLabels',
'TerrainLabels' = 'TerrainLabels'
"OceansLabels" = "OceansLabels",
"GrayLabels" = "GrayLabels",
"DarkGrayLabels" = "DarkGrayLabels",
"ImageryLabels" = "ImageryLabels",
"ImageryTransportation" = "ImageryTransportation",
"ShadedReliefLabels" = "ShadedReliefLabels",
"TerrainLabels" = "TerrainLabels"
)

#' Adds a ArcGIS Basemap layer
Expand All @@ -37,7 +37,7 @@ esriBasemapLabels <- list(
#' @param options Basemap Layer Options. You can pass \code{\link[leaflet]{tileOptions}()}.
#' @examples \dontrun{
#' leaflet() %>%
#' addEsriBasemapLayer(esriBasemapLayers$Oceans, autoLabels=TRUE)
#' addEsriBasemapLayer(esriBasemapLayers$Oceans, autoLabels = TRUE)
#' }
#' @export
addEsriBasemapLayer <- function(
Expand All @@ -47,21 +47,21 @@ addEsriBasemapLayer <- function(

map <- addEsriDependency(map)

if(is.null(options)) {
if (is.null(options)) {
options <- list()
}

if(!(key %in% esriBasemapLayers || key %in% esriBasemapLabels)) {
if (!(key %in% esriBasemapLayers || key %in% esriBasemapLabels)) {
stop("Invalid Basemap layer Key")
}

labelLayer <- NULL
if(autoLabels) {
labelLayer <- esriBasemapLabels[[sprintf("%sLabels",key)]]
if (autoLabels) {
labelLayer <- esriBasemapLabels[[sprintf("%sLabels", key)]]
}

leaflet::invokeMethod(
map, leaflet::getMapData(map),
'addEsriBasemapLayer', key, labelLayer, layerId, group, options)
"addEsriBasemapLayer", key, labelLayer, layerId, group, options)

}
58 changes: 29 additions & 29 deletions R/dynamicMapLayers.R
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
#' Options for dynamic map layer.
#'
#' @param format Output format of the image.
#' @param transparent Allow the server to produce transparent images.
#' @param f Server response content type.
#' @param attribution Attribution from service metadata copyright text is automatically displayed in Leaflet's default control. This property can be used for customization.
#' @param layers An array of Layer IDs like [3,4,5] to show from the service.
#' @param layerDefs A string representing a query to run against the service before the image is rendered. This can be a string like "3:STATE_NAME='Kansas'" or an object mapping different queries to specific layers {3:"STATE_NAME='Kansas'", 2:"POP2007>25000"}.
#' @param opacity Opacity of the layer. Should be a value between 0 (completely transparent) and 1 (completely opaque).
#' @param position Position of the layer relative to other overlays.
#' @param maxZoom Closest zoom level the layer will be displayed on the map.
#' @param minZoom Furthest zoom level the layer will be displayed on the map.
#' @param dynamicLayers JSON object literal used to manipulate the layer symbology defined in the service itself. Requires a 10.1 (or above) map service which supports dynamicLayers requests.
#' @param token If you pass a token in your options it will be included in all requests to the service.
#' @param proxy URL of an \href{https://developers.arcgis.com/javascript/jshelp/ags_proxy.html}{ArcGIS API for JavaScript proxy} or \href{https://github.com/Esri/resource-proxy}{ArcGIS Resource Proxy} to use for proxying requests.
#' @param useCors If this service should use CORS when making GET requests.
#' @param format Output format of the image.
#' @param transparent Allow the server to produce transparent images.
#' @param f Server response content type.
#' @param attribution Attribution from service metadata copyright text is automatically displayed in Leaflet's default control. This property can be used for customization.
#' @param layers An array of Layer IDs like [3, 4, 5] to show from the service.
#' @param layerDefs A string representing a query to run against the service before the image is rendered. This can be a string like "3:STATE_NAME="Kansas"" or an object mapping different queries to specific layers {3:"STATE_NAME="Kansas"", 2:"POP2007>25000"}.
#' @param opacity Opacity of the layer. Should be a value between 0 (completely transparent) and 1 (completely opaque).
#' @param position Position of the layer relative to other overlays.
#' @param maxZoom Closest zoom level the layer will be displayed on the map.
#' @param minZoom Furthest zoom level the layer will be displayed on the map.
#' @param dynamicLayers JSON object literal used to manipulate the layer symbology defined in the service itself. Requires a 10.1 (or above) map service which supports dynamicLayers requests.
#' @param token If you pass a token in your options it will be included in all requests to the service.
#' @param proxy URL of an \href{https://developers.arcgis.com/javascript/jshelp/ags_proxy.html}{ArcGIS API for JavaScript proxy} or \href{https://github.com/Esri/resource-proxy}{ArcGIS Resource Proxy} to use for proxying requests.
#' @param useCors If this service should use CORS when making GET requests.
#' @param ... extra options
#' @export
dynamicMapLayerOptions <- function(
format = 'png24',
format = "png24",
transparent = TRUE,
f = 'json',
attribution = '',
layers = NULL,
f = "json",
attribution = "",
layers = NULL,
layerDefs = NULL,
opacity = 1,
position = 'front',
position = "front",
maxZoom = NULL,
minZoom = NULL,
dynamicLayers = NULL,
token = NULL,
proxy = NULL,
useCors = TRUE,
token = NULL,
proxy = NULL,
useCors = TRUE,
...
) {
leaflet::filterNULL(list(
format = format,
format = format,
transparent = transparent,
f = f,
attribution = attribution,
layers = layers,
layers = layers,
layerDefs = layerDefs,
opacity = opacity,
position = position,
maxZoom = maxZoom,
minZoom = minZoom,
dynamicLayers = dynamicLayers,
token = token,
proxy = proxy,
useCors = useCors,
token = token,
proxy = proxy,
useCors = useCors,
...

))
Expand Down Expand Up @@ -77,11 +77,11 @@ addEsriDynamicMapLayer <- function(
popupFunction = NULL, popupOptions = NULL,
layerId = NULL, group = NULL) {
map <- addEsriDependency(map)
if(is.null(options)) {
if (is.null(options)) {
options <- list()
}
leaflet::invokeMethod(
map, leaflet::getMapData(map),
'addEsriDynamicMapLayer', url, layerId, group,
"addEsriDynamicMapLayer", url, layerId, group,
options, popupFunction, popupOptions)
}
68 changes: 34 additions & 34 deletions R/featureLayers.R
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
#' Options for featureLayers.
#'
#' @param where String An optional expression to filter features server side.
#' String values should be denoted using single quotes ie: where: "FIELDNAME = 'field value'"; More information about valid SQL syntax can be found at \url{http://resources.arcgis.com/en/help/main/10.2/index.html#/SQL_reference_for_query_expressions_used_in_ArcGIS/00s500000033000000/}.
#' @param minZoom Integer Minimum zoom level of the map that features will display.
#' @param where String An optional expression to filter features server side.
#' String values should be denoted using single quotes ie: where: "FIELDNAME = "field value""; More information about valid SQL syntax can be found at \url{http://resources.arcgis.com/en/help/main/10.2/index.html#/SQL_reference_for_query_expressions_used_in_ArcGIS/00s500000033000000/}.
#' @param minZoom Integer Minimum zoom level of the map that features will display.
#' example: minZoom:0
#' @param maxZoom Integer Maximum zoom level of the map that features will
#' @param maxZoom Integer Maximum zoom level of the map that features will
#' example: maxZoom:19
#' @param cacheLayers Boolean Will remove layers from the internal cache when they are removed from the map.
#' @param fields Array An array of fieldnames to pull from the service.
#' Includes all fields by default. You should always specify the name of the unique id for the service. Usually either 'FID' or 'OBJECTID'.
#' @param from Date When paired with to defines the time range of features to display.
#' @param cacheLayers Boolean Will remove layers from the internal cache when they are removed from the map.
#' @param fields Array An array of fieldnames to pull from the service.
#' Includes all fields by default. You should always specify the name of the unique id for the service. Usually either "FID" or "OBJECTID".
#' @param from Date When paired with to defines the time range of features to display.
#' Requires the Feature Layer to be time enabled.
#' @param to Date When paired with from defines the time range of features to display.
#' @param to Date When paired with from defines the time range of features to display.
#' Requires the Feature Layer to be time enabled.
#' @param timeField false The name of the field to lookup the time of the feature.
#' Can be an object like {start:'startTime', end:'endTime'} or a string like 'created'.
#' @param timeFilterMode 'server' (default) or 'client' Determines where features are filtered by time.
#' By default features will be filtered by the server. If set to 'client' all features are requested and filtered by the app before display.
#' @param simplifyFactor Integer How much to simplify polygons and polylines.
#' @param timeField false The name of the field to lookup the time of the feature.
#' Can be an object like {start:"startTime", end:"endTime"} or a string like "created".
#' @param timeFilterMode "server" (default) or "client" Determines where features are filtered by time.
#' By default features will be filtered by the server. If set to "client" all features are requested and filtered by the app before display.
#' @param simplifyFactor Integer How much to simplify polygons and polylines.
#' More means better performance, and less means more accurate representation.
#' @param precision Integer How many digits of precision to request from the server.
#' @param precision Integer How many digits of precision to request from the server.
#' Wikipedia has a great reference of digit precision to meters at \url{http://en.wikipedia.org/wiki/Decimal_degrees}.
#' @param token String If you pass a token in your options it will be included in all requests to the service.
#' @param proxy URL of an \href{https://developers.arcgis.com/javascript/jshelp/ags_proxy.html}{ArcGIS API for JavaScript proxy} or \href{https://github.com/Esri/resource-proxy}{ArcGIS Resource Proxy} to use for proxying requests.
#' @param useCors Boolean If this service should use CORS when making GET requests.
#' @param renderer L.svg or L.canvas The vector renderer to use to draw the service.
#' @param token String If you pass a token in your options it will be included in all requests to the service.
#' @param proxy URL of an \href{https://developers.arcgis.com/javascript/jshelp/ags_proxy.html}{ArcGIS API for JavaScript proxy} or \href{https://github.com/Esri/resource-proxy}{ArcGIS Resource Proxy} to use for proxying requests.
#' @param useCors Boolean If this service should use CORS when making GET requests.
#' @param renderer L.svg or L.canvas The vector renderer to use to draw the service.
#' Usually L.svg but setting to L.canvas contains performance benefits for large polygon layers.
#' @param ... extra options
#' @export
Expand Down Expand Up @@ -78,7 +78,7 @@ featureLayerOptions <- function(
#' @param layerId A unique ID for the layer.
#' @param group The name of the group this layer should be added to.
#' the same parameter under \code{\link{addTiles}})
#' @param markerType The type of marker. either 'marker' or 'circleMarker'
#' @param markerType The type of marker. either "marker" or "circleMarker"
#' @param markerIcons Icons for Marker.
#' @param markerIconProperty The property of the feature to use for marker icon.
#' Can be a JS function which accepts a feature and returns an index of \code{markerIcons}.
Expand Down Expand Up @@ -146,7 +146,7 @@ addEsriFeatureLayer <- function(
map$dependencies <- c(map$dependencies,
leaflet.extras::leafletExtrasDependencies$omnivore())

if(useServiceSymbology) {
if (useServiceSymbology) {
map <- addEsriRenderersDependency(map)
} else {
map <- addEsriDependency(map)
Expand All @@ -157,33 +157,33 @@ addEsriFeatureLayer <- function(
map <- addEsriClusterDependency(map)
}

pathOptions = c(pathOptions, list(
pathOptions <- c(pathOptions, list(
stroke = stroke, color = color, weight = weight, opacity = opacity,
fill = fill, fillColor = fillColor, fillOpacity = fillOpacity,
dashArray = dashArray, smoothFactor = smoothFactor, noClip = noClip))

markerIconFunction <- NULL
if(!is.null(markerIcons)) {
if(inherits(markerIcons,'leaflet_icon_set') ||
inherits(markerIcons, 'leaflet_icon')) {
if (!is.null(markerIcons)) {
if (inherits(markerIcons, "leaflet_icon_set") ||
inherits(markerIcons, "leaflet_icon")) {
markerIconFunction <- defIconFunction
} else if(inherits(markerIcons,'leaflet_awesome_icon_set') ||
inherits(markerIcons, 'leaflet_awesome_icon')) {
if(inherits(markerIcons,'leaflet_awesome_icon_set')) {
libs <- unique(sapply(markerIcons,function(icon) icon$library))
map <- leaflet.extras::addAwesomeMarkersDependencies(map,libs)
} else if (inherits(markerIcons, "leaflet_awesome_icon_set") ||
inherits(markerIcons, "leaflet_awesome_icon")) {
if (inherits(markerIcons, "leaflet_awesome_icon_set")) {
libs <- unique(sapply(markerIcons, function(icon) icon$library))
map <- leaflet.extras::addAwesomeMarkersDependencies(map, libs)
} else {
map <- leaflet.extras::addAwesomeMarkersDependencies(
map,markerIcons$library)
map, markerIcons$library)
}
markerIconFunction <- awesomeIconFunction
} else {
stop('markerIcons should be created using either leaflet::iconList() or leaflet::awesomeIconList()')
stop("markerIcons should be created using either leaflet::iconList() or leaflet::awesomeIconList()")
}
}

leaflet::invokeMethod(
map, leaflet::getMapData(map), 'addEsriFeatureLayer', url, options, layerId, group,
map, leaflet::getMapData(map), "addEsriFeatureLayer", url, options, layerId, group,
markerType, markerIcons,
markerIconProperty, markerOptions, markerIconFunction,
clusterOptions, clusterId,
Expand Down Expand Up @@ -217,5 +217,5 @@ addEsriHeatmapFeatureLayer <- function(
)))
leaflet::invokeMethod(
map, leaflet::getMapData(map),
'addEsriHeatmapFeatureLayer', url, layerId, group, options)
"addEsriHeatmapFeatureLayer", url, layerId, group, options)
}
10 changes: 5 additions & 5 deletions R/htmlDependencies.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
esriDependency <- function() {
list(
htmltools::htmlDependency(
"esri.leaflet",version = "1.0.4",
"esri.leaflet", version = "1.0.4",
system.file("htmlwidgets/lib/esri", package = "leaflet.esri"),
script = c("esri-leaflet.js", "esri-leaflet-bindings.js")
)
Expand All @@ -20,7 +20,7 @@ addEsriDependency <- function(map) {
esriClusterDependency <- function() {
list(
htmltools::htmlDependency(
"esri.leaflet.cluster",version = "1.0.2",
"esri.leaflet.cluster", version = "1.0.2",
system.file("htmlwidgets/lib/esri-cluster", package = "leaflet.esri"),
script = c("esri-leaflet-clustered-feature-layer-src.js")
)
Expand All @@ -41,7 +41,7 @@ addEsriClusterDependency <- function(map) {
esriGeocoderDependency <- function() {
list(
htmltools::htmlDependency(
"esri.leaflet.geocoder",version = "1.0.2",
"esri.leaflet.geocoder", version = "1.0.2",
system.file("htmlwidgets/lib/esri-geocoder", package = "leaflet.esri"),
script = c("esri-leaflet-geocoder.js"),
stylesheet = c("esri-leaflet-geocoder.css")
Expand All @@ -62,7 +62,7 @@ addEsriGeocoderDependency <- function(map) {
esriHeatmapDependency <- function() {
list(
htmltools::htmlDependency(
"esri.leaflet.heatmap",version = "1.0.2",
"esri.leaflet.heatmap", version = "1.0.2",
system.file("htmlwidgets/lib/esri-heatmap", package = "leaflet.esri"),
script = c("leaflet-heat.js",
"esri-leaflet-heatmap-feature-layer.js")
Expand All @@ -83,7 +83,7 @@ addEsriHeatmapDependency <- function(map) {
esriRenderersDependency <- function() {
list(
htmltools::htmlDependency(
"esri.leaflet.renderers",version = "1.0.2",
"esri.leaflet.renderers", version = "1.0.2",
system.file("htmlwidgets/lib/esri-renderers", package = "leaflet.esri"),
script = c("esri-leaflet-renderers.js")
)
Expand Down
6 changes: 3 additions & 3 deletions R/iconFunctions.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
defIconFunction <-
JS("function(icon){
if(!$.isEmptyObject(icon)) {
if (!$.isEmptyObject(icon)) {
return L.icon(icon);
} else {
return L.icon();
Expand All @@ -9,8 +9,8 @@ defIconFunction <-

awesomeIconFunction <-
JS("function(icon){
if(!$.isEmptyObject(icon)) {
if(!icon.prefix) {
if (!$.isEmptyObject(icon)) {
if (!icon.prefix) {
icon.prefix = icon.library;
}
return L.AwesomeMarkers.icon(icon);
Expand Down
Loading

0 comments on commit 680cbef

Please sign in to comment.