# Wed Sep 02 20:39:27 2020 -
# 字符编码:UTF-8
# R 版本:R x64 4.0.2 for window 10
# cgh163email@163.com
# 个人笔记不负责任
# —— 拎了个梨🍐
rm(list=ls());gc()
.rs.restartR()
require(mapdeck)
# key <- 'abc'
set_token( key )
# Wed Sep 02 20:44:34 2020 -加载地图矢量多边形-----------------------------
library(geojsonsf)
sf <- geojsonsf::geojson_sf("https://geo.datav.aliyun.com/areas_v2/bound/440000_full.json")
names(sf)
# Wed Sep 02 20:44:58 2020 --作图
mapdeck(
style = mapdeck_style('dark')
) %>%
add_polygon(
data = sf
, layer = "polygon_layer"
# , fill_colour = "name" # 填色参数经常出错
)
# Wed Sep 02 20:45:34 2020 ---自带地图数据演示---------------------------
df <- melbourne ## 具有编码多义性的data.frame
df$elevation <- sample(100:5000, size = nrow(df))
df$info <- paste0("<b>SA2 - </b><br>",df$SA2_NAME)
mapdeck(pitch = 45,
style = mapdeck_style('dark')
, location = c(145, -38)
, zoom = 8
) %>%
add_polygon(
data = df
, polyline = "geometry" # 不影响
, layer = "polygon_layer" # 不影响
# , fill_colour = "SA2_NAME" # 填色经常出错
, elevation = "elevation" # 高程倍数
, tooltip = 'info' # 备注信息
, legend = T # 图例?
,auto_highlight = T # 自动高亮鼠标位置
)
空格分隔的表格:
1 map a mapdeck map object 一个mapdeck地图对象
2 data data to be used in the layer. All coordinates are expected to be EPSG:4326 (WGS 84) coordinate system 图层中要使用的数据。所有坐标均应为EPSG:4326(WGS 84)坐标系
3 polyline optional column of data containing the polylines, if using encoded polylines 如果使用编码折线,则包含折线的数据的可选列
4 stroke_colour variable of data or hex colour for the stroke. If used, elevation is ignored. If using a hex colour, use either a single value, or a column of hex colours on data 笔画的数据变量或十六进制颜色。如果使用,则忽略高程。如果使用十六进制颜色,请在数据上使用单个值或一列十六进制颜色
5 stroke_width width of the stroke in meters. If used, elevation is ignored. Default 1. 笔画的宽度(以米为单位)。如果使用,则忽略高程。默认值1。
6 stroke_opacity Either a string specifying the column of data containing the opacity of each shape, or a single value in [0,255], or [0, 1), to be applied to all the shapes. Default 255. If a hex-string is used as the colour, this argument is ignored and you should include the alpha on the hex string 指定包含每个形状的不透明度的数据列的字符串,或者是[0,255]或[0,1)中的单个值,将应用于所有形状。默认值255。如果将十六进制字符串用作颜色,则将忽略此参数,并且应在十六进制字符串中包含alpha
7 fill_colour column of data or hex colour for the fill colour. If using a hex colour, use either a single value, or a column of hex colours on data 数据列或十六进制颜色作为填充色。如果使用十六进制颜色,请在数据上使用单个值或一列十六进制颜色
8 fill_opacity Either a string specifying the column of data containing the opacity of each shape, or a single value in [0,255], or [0, 1), to be applied to all the shapes. Default 255. If a hex-string is used as the colour, this argument is ignored and you should include the alpha on the hex string 指定包含每个形状的不透明度的数据列的字符串,或者是[0,255]或[0,1)中的单个值,将应用于所有形状。默认值255。如果将十六进制字符串用作颜色,则将忽略此参数,并且应在十六进制字符串中包含alpha
9 elevation the height the polygon extrudes from the map. Only available if neitherstroke_colour or stroke_width are supplied. Default 0 多边形从地图突出的高度。仅在未提供stroke_colour或stroke_width时可用。默认值0
10 tooltip variable of data containing text or HTML to render as a tooltip 包含文本或HTML的数据变量以呈现为工具提示
11 auto_highlight logical indicating if the shape under the mouse should auto-highlight 逻辑指示鼠标下方的形状是否应自动突出显示
12 elevation_scale elevation multiplier. 高程乘数。
13 highlight_colour hex string colour to use for highlighting. Must contain the alpha component. 用于突出显示的十六进制字符串颜色。必须包含alpha分量。
14 light_settings list of light setting parameters. See light_settings 灯光设置参数列表。参见light_settings
15 layer_id single value specifying an id for the layer. Use this value to distinguish between shape layers of the same type. Layers with the same id are likely to conflict and not plot correctly 指定图层ID的单个值。使用此值可以区分相同类型的形状图层。具有相同ID的图层可能会发生冲突并且无法正确绘制
16 id an id value in data to identify layers when interacting in Shiny apps. 数据中的ID值,以在“闪亮”应用程序中进行交互时识别图层。
17 palette "string or matrix. String will be one of colourvalues::colour_palettes(). A matrix must have at least 5 rows, and 3 or 4 columns of values between [0, 255], where the 4th column represents the alpha. You can use a named list to specify a different palette for different colour options (where available), e.g. list(fill_colour = "viridis", stroke_colour = "inferno")" “字符串或矩阵。字符串将是colourvalues :: colour_palettes()之一。矩阵必须至少包含5行,且[0,255]之间的值包含3或4列,其中第4列表示Alpha。您可以使用命名列表为不同的颜色选项(如果有)指定不同的调色板,例如list(fill_colour =“ viridis”,stroke_colour =“ inferno”)“
18 na_colour hex string colour to use for NA values 用于NA值的十六进制字符串颜色
19 legend either a logical indiciating if the legend(s) should be displayed, or a named list indicating which colour attributes should be included in the legend. 逻辑指示是否应显示图例,或者是一个命名列表,该列表指示应在图例中包括哪些颜色属性。
20 legend_options A list of options for controlling the legend. 用于控制图例的选项列表。
21 legend_format A list containing functions to apply to legend values. See section legend 包含要应用于图例值的函数的列表。参见图例
22 update_view logical indicating if the map should update the bounds to include this layer 逻辑指示地图是否应更新边界以包括此图层
23 focus_layer logical indicating if the map should update the bounds to only include this layer 逻辑指示地图是否应将边界更新为仅包括此图层
24 digits number of digits for rounding coordinates 舍入坐标的位数
25 transitions list specifying the duration of transitions. 指定过渡持续时间的列表。
26 brush_radius radius of the brush in metres. Default NULL. If supplied, the arcs will only show if the origin or destination are within the radius of the mouse. If NULL, all arcs are displayed 画笔的半径(以米为单位)。默认为NULL。如果提供了弧,则仅当起点或终点在鼠标的半径内时才会显示弧。如果为NULL,则显示所有弧