在我的地图绘制应用程序中,我可以高亮显示多边形,当鼠标悬停或选择它时,但是无法突出显示point和lineString,我想在脚本中添加了样式。
我在网上发现了一些ol.featureOverlay
的工作示例,但现在在新的openlayers3中,ol.featureOverlay
已从库中删除,有些专家知道如何解决它吗?
答案 0 :(得分:1)
告诉您的互动,阅读您function
的样式:
var hoverInteraction = new ol.interaction.Select({
condition: ol.events.condition.pointerMove,
style: geometryStyle
});
你的功能将如上所述:
function geometryStyle(feature){
var
style = [],
geometry_type = feature.getGeometry().getType(),
white = [255, 255, 255, 1],
blue = [0, 153, 255, 1],
width = 6
;
style['LineString'] = [
new ol.style.Style({
stroke: new ol.style.Stroke({
color: white, width: width + 2
})
}),
new ol.style.Style({
stroke: new ol.style.Stroke({
color: blue, width: width
})
})
],
style['Polygon'] = [
new ol.style.Style({
fill: new ol.style.Fill({ color: [255, 255, 255, 0.5] })
}),
new ol.style.Style({
stroke: new ol.style.Stroke({
color: white, width: 3.5
})
}),
new ol.style.Style({
stroke: new ol.style.Stroke({
color: blue, width: 2.5
})
})
],
style['Point'] = [
new ol.style.Style({
image: new ol.style.Circle({
radius: width * 2,
fill: new ol.style.Fill({color: blue}),
stroke: new ol.style.Stroke({
color: white, width: width / 2
})
})
})
];
return style[geometry_type];
}