Ivan asked a question about adding static features to a map.
Using an example of Holbeach military range in the UK, here’s how it’s done:
In script.js, around line 501, after:
OLMap.on('click', 'dblclick'], function(evt) {
var hex = evt.map.forEachFeatureAtPixel(evt.pixel,
function(feature, layer) {
return feature.hex;
},
null,
function(layer) {
return (layer === iconsLayer);
},
null);
if (hex) {
selectPlaneByHex(hex, (evt.type === 'dblclick'));
evt.stopPropagation();
}
});
Insert:
var dangerAreaStyle = new ol.style.Style({
fill: new ol.style.Fill({
color : 'rgba(255, 0, 0, 0.1)'
}),
stroke: new ol.style.Stroke({
color: '#FF0000',
width: 0.5
})
});
var polyCoords = ];
var milD207c =
[52.806497,0.302124],
[52.806082,0.202560],
[52.894820,0.106430],
[52.932500,0.142822],
[52.946569,0.166855],
[52.953189,0.184021],
[52.960221,0.206680],
[52.963116,0.230713],
[52.964357,0.262299],
[52.960634,0.292511],
[52.955257,0.312424],
[52.946569,0.335770],
[52.935811,0.352249],
[52.928775,0.361862],
[52.883634,0.409927]
];
for (var i = 0; i in milD207c ; i = i + 1) {
polyCoords.push(ol.proj.transform([milD207c*[1], milD207c*[0]], 'EPSG:4326', 'EPSG:3857'));
}
var d207 = new ol.geom.Polygon([polyCoords]);
var areaD207 = new ol.Feature({geometry:d207, name:'Danger Area<br>D207'});
areaD207.setStyle(dangerAreaStyle);
StaticFeatures.push(areaD207);
// Add home marker if requested <-- existing line
to give:
https://dl.dropboxusercontent.com/u/12973352/d207.jpg*