Description Usage Arguments Examples
This is a feature rich alternative to the addGeoJSON
& addTopoJSON
with options to map feature properties to labels, popups, colors, markers etc.
Options to customize a Choropleth Legend
Adds a GeoJSON/TopoJSON Choropleth.
Adds a KML to the leaflet map.
Adds a KML Choropleth.
Options for parsing CSV
Adds a CSV to the leaflet map.
Adds a GPX to the leaflet map.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | addGeoJSONv2(map, geojson, layerId = NULL, group = NULL,
markerType = NULL, markerIcons = NULL, markerIconProperty = NULL,
markerOptions = leaflet::markerOptions(), clusterOptions = NULL,
clusterId = NULL, labelProperty = NULL,
labelOptions = leaflet::labelOptions(), popupProperty = NULL,
popupOptions = leaflet::popupOptions(), stroke = TRUE, color = "#03F",
weight = 5, opacity = 0.5, fill = TRUE, fillColor = color,
fillOpacity = 0.2, dashArray = NULL, smoothFactor = 1, noClip = FALSE,
pathOptions = leaflet::pathOptions(), highlightOptions = NULL)
legendOptions(title = NULL, position = c("bottomleft", "bottomright",
"topleft", "topright"), locale = "en-US", numberFormatOptions = list(style
= "decimal", maximumFractionDigits = 2))
addGeoJSONChoropleth(map, geojson, layerId = NULL, group = NULL,
valueProperty, labelProperty = NULL,
labelOptions = leaflet::labelOptions(), popupProperty = NULL,
popupOptions = leaflet::popupOptions(), scale = c("white", "red"),
steps = 5, mode = "q", channelMode = c("rgb", "lab", "hsl", "lch"),
padding = NULL, correctLightness = FALSE, bezierInterpolate = FALSE,
colors = NULL, stroke = TRUE, color = "#03F", weight = 1,
opacity = 0.5, fillOpacity = 0.2, dashArray = NULL, smoothFactor = 1,
noClip = FALSE, pathOptions = leaflet::pathOptions(),
highlightOptions = NULL, legendOptions = NULL)
addKML(map, kml, layerId = NULL, group = NULL, markerType = NULL,
markerIcons = NULL, markerIconProperty = NULL,
markerOptions = leaflet::markerOptions(), clusterOptions = NULL,
clusterId = NULL, labelProperty = NULL,
labelOptions = leaflet::labelOptions(), popupProperty = NULL,
popupOptions = leaflet::popupOptions(), stroke = TRUE, color = "#03F",
weight = 5, opacity = 0.5, fill = TRUE, fillColor = color,
fillOpacity = 0.2, dashArray = NULL, smoothFactor = 1, noClip = FALSE,
pathOptions = leaflet::pathOptions(), highlightOptions = NULL)
addKMLChoropleth(map, kml, layerId = NULL, group = NULL, valueProperty,
labelProperty = NULL, labelOptions = leaflet::labelOptions(),
popupProperty = NULL, popupOptions = leaflet::popupOptions(),
scale = c("white", "red"), steps = 5, mode = "q",
channelMode = c("rgb", "lab", "hsl", "lch"), padding = NULL,
correctLightness = FALSE, bezierInterpolate = FALSE, colors = NULL,
stroke = TRUE, color = "#03F", weight = 1, opacity = 0.5,
fillOpacity = 0.2, dashArray = NULL, smoothFactor = 1, noClip = FALSE,
pathOptions = leaflet::pathOptions(), highlightOptions = NULL,
legendOptions = NULL)
csvParserOptions(latfield, lonfield, delimiter = ",")
addCSV(map, csv, csvParserOptions, layerId = NULL, group = NULL,
markerType = NULL, markerIcons = NULL, markerIconProperty = NULL,
markerOptions = leaflet::markerOptions(), clusterOptions = NULL,
clusterId = NULL, labelProperty = NULL,
labelOptions = leaflet::labelOptions(), popupProperty = NULL,
popupOptions = leaflet::popupOptions(), stroke = TRUE, color = "#03F",
weight = 5, opacity = 0.5, fill = TRUE, fillColor = color,
fillOpacity = 0.2, dashArray = NULL, smoothFactor = 1, noClip = FALSE,
pathOptions = leaflet::pathOptions(), highlightOptions = NULL)
addGPX(map, gpx, layerId = NULL, group = NULL, markerType = NULL,
markerIcons = NULL, markerIconProperty = NULL,
markerOptions = leaflet::markerOptions(), clusterOptions = NULL,
clusterId = NULL, labelProperty = NULL,
labelOptions = leaflet::labelOptions(), popupProperty = NULL,
popupOptions = leaflet::popupOptions(), stroke = TRUE, color = "#03F",
weight = 5, opacity = 0.5, fill = TRUE, fillColor = color,
fillOpacity = 0.2, dashArray = NULL, smoothFactor = 1, noClip = FALSE,
pathOptions = leaflet::pathOptions(), highlightOptions = NULL)
|
map |
the leaflet map widget |
geojson |
a GeoJSON/TopoJSON URL or file contents in a character vector. |
layerId |
the layer id |
group |
the name of the group this raster image should belong to (see
the same parameter under |
markerType |
The type of marker. either "marker" or "circleMarker" |
markerIcons |
Icons for Marker.
Can be a single marker using |
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 |
markerOptions |
The options for markers |
clusterOptions |
if not |
clusterId |
the id for the marker cluster layer |
labelProperty |
The property to use for the label. You can also pass in a JS function that takes in a feature and returns a text/HTML content. |
labelOptions |
A Vector of |
popupProperty |
The property to use for popup content You can also pass in a JS function that takes in a feature and returns a text/HTML content. |
popupOptions |
A Vector of |
stroke |
whether to draw stroke along the path (e.g. the borders of polygons or circles) |
color |
stroke color |
weight |
stroke width in pixels |
opacity |
stroke opacity (or layer opacity for tile layers) |
fill |
whether to fill the path with color (e.g. filling on polygons or circles) |
fillColor |
fill color |
fillOpacity |
fill opacity |
dashArray |
a string that defines the stroke dash pattern |
smoothFactor |
how much to simplify the polyline on each zoom level (more means better performance and less accurate representation) |
noClip |
whether to disable polyline clipping |
pathOptions |
Options for shapes |
highlightOptions |
Options for highlighting the shape on mouse over.
options for each label. Default |
title |
An optional title for the legend |
position |
legend position |
locale |
The numbers will be formatted using this locale |
numberFormatOptions |
Options for formatting numbers |
valueProperty |
The property to use for coloring |
scale |
The scale to use from chroma.js |
steps |
number of breakes |
mode |
q for quantile, e for equidistant, k for k-means |
channelMode |
Default "rgb", can be one of "rgb", "lab", "hsl", "lch" |
padding |
either a single number or a 2 number vector for clipping color values at ends. |
correctLightness |
whether to correct lightness |
bezierInterpolate |
whether to use bezier interpolate for determining colors |
colors |
overrides scale with manual colors |
legendOptions |
Options to show a legend. |
kml |
a KML URL or contents in a character vector. |
latfield |
field name for latitude |
lonfield |
field name for longitude |
delimiter |
field separator |
csv |
a CSV URL or contents in a character vector. |
csvParserOptions |
options for parsing the CSV.
Use |
gpx |
a GPX URL or contents in a character vector. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | ## addGeoJSONv2
geoJson <- readr::read_file(
"https://rawgit.com/benbalter/dc-maps/master/maps/historic-landmarks-points.geojson"
)
leaflet() %>%
setView(-77.0369, 38.9072, 12) %>%
addProviderTiles(providers$CartoDB.Positron) %>%
addWebGLGeoJSONHeatmap(
geoJson, size = 30 , units = "px"
) %>%
addGeoJSONv2(
geoJson,
markerType = "circleMarker",
stroke = FALSE, fillColor = "black", fillOpacity = 0.7,
markerOptions = markerOptions(radius = 2)
)
## for more examples see
# browseURL(system.file("examples/draw.R", package = "leaflet.extras"))
# browseURL(system.file("examples/geojsonv2.R", package = "leaflet.extras"))
# browseURL(system.file("examples/search.R", package = "leaflet.extras"))
# browseURL(system.file("examples/TopoJSON.R", package = "leaflet.extras"))
## addGeoJSONChoropleth
geoJson <- readr::read_file(
"https://rawgit.com/benbalter/dc-maps/master/maps/ward-2012.geojson"
)
leaflet() %>%
addTiles() %>%
setView(-77.0369, 38.9072, 11) %>%
addBootstrapDependency() %>%
enableMeasurePath() %>%
addGeoJSONChoropleth(
geoJson,
valueProperty = "AREASQMI",
scale = c("white", "red"),
mode = "q",
steps = 4,
padding = c(0.2, 0),
labelProperty = "NAME",
popupProperty = propstoHTMLTable(
props = c("NAME", "AREASQMI", "REP_NAME", "WEB_URL", "REP_PHONE", "REP_EMAIL", "REP_OFFICE"),
table.attrs = list(class = "table table-striped table-bordered"),
drop.na = TRUE
),
color = "#ffffff", weight = 1, fillOpacity = 0.7,
highlightOptions = highlightOptions(
weight = 2, color = "#000000",
fillOpacity = 1, opacity = 1,
bringToFront = TRUE, sendToBack = TRUE),
pathOptions = pathOptions(
showMeasurements = TRUE,
measurementOptions = measurePathOptions(imperial = TRUE)))
## for more examples see
# browseURL(system.file("examples/geojsonv2.R", package = "leaflet.extras"))
# browseURL(system.file("examples/measurePath.R", package = "leaflet.extras"))
# browseURL(system.file("examples/search.R", package = "leaflet.extras"))
# browseURL(system.file("examples/TopoJSON.R", package = "leaflet.extras"))
## addKML
kml <- readr::read_file(
system.file("examples/data/kml/crimes.kml.zip", package = "leaflet.extras")
)
leaflet() %>%
setView(-77.0369, 38.9072, 12) %>%
addProviderTiles(providers$CartoDB.Positron) %>%
addWebGLKMLHeatmap(kml, size = 20, units = "px") %>%
addKML(
kml,
markerType = "circleMarker",
stroke = FALSE, fillColor = "black", fillOpacity = 1,
markerOptions = markerOptions(radius = 1)
)
## addKMLChoropleth
kml <- readr::read_file(
system.file("examples/data/kml/cb_2015_us_state_20m.kml.zip", package = "leaflet.extras")
)
leaflet() %>%
addBootstrapDependency() %>%
setView(-98.583333, 39.833333, 4) %>%
addProviderTiles(providers$CartoDB.Positron) %>%
addKMLChoropleth(
kml,
valueProperty = JS(
'function(feature){
var props = feature.properties;
var aland = props.ALAND/100000;
var awater = props.AWATER/100000;
return 100*awater/(awater+aland);
}'
),
scale = "OrRd", mode = "q", steps = 5,
padding = c(0.2, 0),
popupProperty = "description",
labelProperty = "NAME",
color = "#ffffff", weight = 1, fillOpacity = 1,
highlightOptions = highlightOptions(
fillOpacity = 1, weight = 2, opacity = 1, color = "#000000",
bringToFront = TRUE, sendToBack = TRUE
),
legendOptions = legendOptions(
title = "% of Water Area",
numberFormatOptions = list(
style = "decimal",
maximumFractionDigits = 2
)
)
)
## addCSV
csv <- readr::read_file(
system.file("examples/data/csv/world_airports.csv.zip", package = "leaflet.extras")
)
leaflet() %>%
setView(0, 0, 2) %>%
addProviderTiles(providers$CartoDB.DarkMatterNoLabels) %>%
addCSV(
csv,
csvParserOptions("latitude_deg", "longitude_deg"),
markerType = "circleMarker",
stroke = FALSE, fillColor = "red", fillOpacity = 1,
markerOptions = markerOptions(radius = 0.5))
## addGPX
airports <- readr::read_file(
system.file("examples/data/gpx/md-airports.gpx.zip", package = "leaflet.extras")
)
leaflet() %>%
addBootstrapDependency() %>%
setView(-76.6413, 39.0458, 8) %>%
addProviderTiles(
providers$CartoDB.Positron,
options = providerTileOptions(detectRetina = TRUE)
) %>%
addWebGLGPXHeatmap(airports, size = 20000, group = "airports", opacity = 0.9) %>%
addGPX(
airports,
markerType = "circleMarker",
stroke = FALSE, fillColor = "black", fillOpacity = 1,
markerOptions = markerOptions(radius = 1.5),
group = "airports"
)
## for a larger example see
# browseURL(system.file("examples/GPX.R", package = "leaflet.extras"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.