一、选择的地区高亮
以中国地图为例,默认显示中国地图,点击省市,点击区域高亮显示
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: