I am a beginner to OpenLayers,and what i'm trying to do is to create multiple vector layers with one GeoJSON in OpenLayers 3. Here is a small part of the GeoJSON file.
{"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [ 7.07,44.91 ]
},
"properties": {
"Type":"Animals",
"JS_Date":1470433175,
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [ 5.97,44.78 ]
},
"properties": {
"Type":"Contaminations",
"JS_Date":1470433145,
}
},
……]
}
I read an old topic about that, but i didn't manage to adapt his solution to mine.
What I’m trying to do, is to create two different layers depending on the GeoJSON properties. therefor I want a layer with all features which have as properties type “Animals” and another layer with all features which have as properties type “Contaminations”.
Currently the code I have to display features in one layer is this one:
var GeoJsonDATA=new ol.layer.Vector({
source: new ol.source.Vector({
url: '../Data/Observations.geojson',
format: new ol.format.GeoJSON()
}),
name: ‘UserData’,
});