JSRUN 用代码说话

设置特定的地图区域

编辑教程

设置特定的地图区域


geo.regions[i]

Object 在地图中对特定的区域配置样式。

例如:

regions: [{
    name: '广东',
    itemStyle: {
        normal: {
            areaColor: 'red',
            color: 'red'
        }
    }
}]

geo 区域的颜色也可以被 map series 所控制,参见 series-map.geoIndex。


geo.regions[i].name

string 地图中特定区域的名称,例如 '广东','浙江'。


geo.regions[i].selected

boolean [ 默认值: false ]

是否选中该特定区域。


geo.regions[i].itemStyle

Object 该特定区域的多边形样式设置。


geo.regions[i].itemStyle.normal

Object 在 normal 状态下设置地图中特定区域的多边形样式。


geo.regions[i].itemStyle.normal.areaColor

Color 地图区域的颜色。


geo.regions[i].itemStyle.normal.color

Color [ 默认值: 自适应 ]

图形的颜色。

颜色可以使用 RGB 表示,比如 'rgb(128, 128, 128)',如果想要加上 alpha 通道表示不透明度,可以使用 RGBA,比如 'rgba(128, 128, 128, 0.5)',也可以使用十六进制格式,比如 '#ccc'。除了纯色之外颜色也支持渐变色和纹理填充。

// 线性渐变,前四个参数分别是 x0, y0, x2, y2, 范围从 0 - 1,相当于在图形包围盒中的百分比,如果 globalCoord 为 `true`,则该四个值是绝对的像素位置
color: {
    type: 'linear',
    x: 0,
    y: 0,
    x2: 0,
    y2: 1,
    colorStops: [{
        offset: 0, color: 'red' // 0% 处的颜色
    }, {
        offset: 1, color: 'blue' // 100% 处的颜色
    }],
    globalCoord: false // 缺省为 false
}
// 径向渐变,前三个参数分别是圆心 x, y 和半径,取值同线性渐变
color: {
    type: 'radial',
    x: 0.5,
    y: 0.5,
    r: 0.5,
    colorStops: [{
        offset: 0, color: 'red' // 0% 处的颜色
    }, {
        offset: 1, color: 'blue' // 100% 处的颜色
    }],
    globalCoord: false // 缺省为 false
}
// 纹理填充
color: {
    image: imageDom, // 支持为 HTMLImageElement, HTMLCanvasElement,不支持路径字符串
    repeat: 'repeat' // 是否平铺, 可以是 'repeat-x', 'repeat-y', 'no-repeat'
}

geo.regions[i].itemStyle.normal.borderColor

Color [ 默认值: "#000" ]

图形的描边颜色。支持的颜色格式同 color,不支持回调函数。


geo.regions[i].itemStyle.normal.borderWidth

number [ 默认值: 0 ]

描边线宽。为 0 时无描边。


geo.regions[i].itemStyle.normal.borderType

string [ 默认值: 'solid' ]

柱条的描边类型,默认为实线,支持 'solid', 'dashed', 'dotted'。


geo.regions[i].itemStyle.normal.shadowBlur

number

图形阴影的模糊大小。该属性配合 shadowColor,shadowOffsetX, shadowOffsetY 一起设置图形的阴影效果。

示例:

{
    shadowColor: 'rgba(0, 0, 0, 0.5)',
    shadowBlur: 10
}

geo.regions[i].itemStyle.normal.shadowColor

Color 阴影颜色。支持的格式同color。


geo.regions[i].itemStyle.normal.shadowOffsetX

number [ 默认值: 0 ]

阴影水平方向上的偏移距离。


geo.regions[i].itemStyle.normal.shadowOffsetY

number [ 默认值: 0 ]

阴影垂直方向上的偏移距离。


geo.regions[i].itemStyle.normal.opacity

number 图形透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形。


geo.regions[i].itemStyle.emphasis

Object 在 emphasis 状态下设置地图中特定区域的多边形样式。


geo.regions[i].itemStyle.emphasis.areaColor

Color 地图区域的颜色。


geo.regions[i].itemStyle.emphasis.color

Color [ 默认值: 自适应 ]

图形的颜色。

颜色可以使用 RGB 表示,比如 'rgb(128, 128, 128)',如果想要加上 alpha 通道表示不透明度,可以使用 RGBA,比如 'rgba(128, 128, 128, 0.5)',也可以使用十六进制格式,比如 '#ccc'。除了纯色之外颜色也支持渐变色和纹理填充。

// 线性渐变,前四个参数分别是 x0, y0, x2, y2, 范围从 0 - 1,相当于在图形包围盒中的百分比,如果 globalCoord 为 `true`,则该四个值是绝对的像素位置
color: {
    type: 'linear',
    x: 0,
    y: 0,
    x2: 0,
    y2: 1,
    colorStops: [{
        offset: 0, color: 'red' // 0% 处的颜色
    }, {
        offset: 1, color: 'blue' // 100% 处的颜色
    }],
    globalCoord: false // 缺省为 false
}
// 径向渐变,前三个参数分别是圆心 x, y 和半径,取值同线性渐变
color: {
    type: 'radial',
    x: 0.5,
    y: 0.5,
    r: 0.5,
    colorStops: [{
        offset: 0, color: 'red' // 0% 处的颜色
    }, {
        offset: 1, color: 'blue' // 100% 处的颜色
    }],
    globalCoord: false // 缺省为 false
}
// 纹理填充
color: {
    image: imageDom, // 支持为 HTMLImageElement, HTMLCanvasElement,不支持路径字符串
    repeat: 'repeat' // 是否平铺, 可以是 'repeat-x', 'repeat-y', 'no-repeat'
}

geo.regions[i].itemStyle.emphasis.borderColor

Color [ 默认值: "#000" ]

图形的描边颜色。支持的颜色格式同 color,不支持回调函数。


geo.regions[i].itemStyle.emphasis.borderWidth

number [ 默认值: 0 ]

描边线宽。为 0 时无描边。


geo.regions[i].itemStyle.emphasis.borderType

string [ 默认值: 'solid' ]

柱条的描边类型,默认为实线,支持 'solid', 'dashed', 'dotted'。


geo.regions[i].itemStyle.emphasis.shadowBlur

number 图形阴影的模糊大小。该属性配合 shadowColor,shadowOffsetX, shadowOffsetY 一起设置图形的阴影效果。

示例:

{
    shadowColor: 'rgba(0, 0, 0, 0.5)',
    shadowBlur: 10
}

geo.regions[i].itemStyle.emphasis.shadowColor

Color 阴影颜色。支持的格式同color。


geo.regions[i].itemStyle.emphasis.shadowOffsetX

number [ 默认值: 0 ]

阴影水平方向上的偏移距离。


geo.regions[i].itemStyle.emphasis.shadowOffsetY

number [ 默认值: 0 ]

阴影垂直方向上的偏移距离。


geo.regions[i].itemStyle.emphasis.opacity

number

图形透明度。

支持从 0 到 1 的数字,为 0 时不绘制该图形。

JSRUN闪电教程系统是国内最先开创的教程维护系统, 所有工程师都可以参与共同维护的闪电教程,让知识的积累变得统一完整、自成体系。 大家可以一起参与进共编,让零散的知识点帮助更多的人。
X
支付宝
9.99
无法付款,请点击这里
金额: 0
备注:
转账时请填写正确的金额和备注信息,到账由人工处理,可能需要较长时间
如有疑问请联系QQ:565830900
正在生成二维码, 此过程可能需要15秒钟