Openlayers 点击地图 行政地区高亮显示

一、选择的地区高亮

以中国地图为例,默认显示中国地图,点击省市,点击区域高亮显示

Openlayers 点击地图 行政地区高亮显示_第1张图片

1、定义高亮区域的样式:

var highlightStyle = new ol.style.Style({
   
    fill: new ol.style.Fill({
   
        color:"#245189",	//高亮区域填充颜色,可用rgba值
    }),
    stroke: new ol.style.Stroke({
   
        color:"#3e84cf",	//高亮区域的边界线颜色
        width:2
    })
});
2、定义高亮区域的图层:
var highlightSource = new ol.source.Vector();
var highlightLayer = new ol.layer.Vector({
   
    source: highlightSource,
    style: highlightStyle
})

3、将2中定义的高亮区域图层添加到地图中:

var view = new ol.View({
   
    center: [117.40077514648436, 39.222336516824625],
    zoom: 1,
    projection: 

你可能感兴趣的:(openlayers,前端,可视化,javascript)