Use ol.style.Style and construct style object once
This commit is contained in:
@@ -82,17 +82,19 @@ map.on('singleclick', function(evt) {
|
|||||||
displayFeatureInfo(pixel);
|
displayFeatureInfo(pixel);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var highlightStyle = new ol.style.Style({
|
||||||
|
stroke: new ol.style.Stroke({
|
||||||
|
color: '#f00',
|
||||||
|
width: 1
|
||||||
|
}),
|
||||||
|
fill: new ol.style.Fill({
|
||||||
|
color: 'rgba(255,0,0,0.1)'
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
map.on('postcompose', function(evt) {
|
map.on('postcompose', function(evt) {
|
||||||
if (highlight) {
|
if (highlight) {
|
||||||
var render = evt.getRender();
|
var render = evt.getRender();
|
||||||
render.drawFeature(highlight, {
|
render.drawFeature(highlight, highlightStyle);
|
||||||
stroke: new ol.style.Stroke({
|
|
||||||
color: '#f00',
|
|
||||||
width: 1
|
|
||||||
}),
|
|
||||||
fill: new ol.style.Fill({
|
|
||||||
color: 'rgba(255,0,0,0.1)'
|
|
||||||
})
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user