I have a GeoJSON file in which each feature has two geometry attributes, one is the default geometry property defined by the GeoJSON standar, and the other one is a property under the standarized properties entry. My intention is, render each geometry with a different style.
Following you can find an example of a GeoJSON feature, and the attempt to define the OpenLayers style.
{
"type": "FeatureCollection",
"crs": {
"type": "name",
"properties": {
"name": "CRS:84"
}
},
"features": [
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-13.7331,
43.0833
],
[
-12.6167,
41.85
],
[
-19.7833,
37.8833
],
[
-20.9333,
39.0333
],
[
-13.7331,
43.0833
]
]
]
},
"properties": {
"type": "StaticAre",
"name": "nameValue",
"test-attr1": "test-attr1",
"geom_alt": {
"type": "Polygon",
"coordinates": [
[
[
-13.7333,
43.0833
],
[
-12.6167,
41.85
],
[
-19.7833,
37.8833
],
[
-20.9333,
39.0333
],
[
-13.7333,
43.0833
]
]
]
}
},
"id": "6764"
}
]
}
var style = [
new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'red',
width: 2
})
}),
new ol.style.Style({
geometry: 'geom_alt',
stroke: new ol.style.Stroke({
color: 'green',
width: 2
})
})
];
I think that the problem is related with that openlayers does not identified the 'geom_alt' property as a geometry.
Do you know if there is a way of doing this?