Use ol.format.GeoJSON in geojson example
This commit is contained in:
@@ -62,9 +62,14 @@ var styleFunction = function(feature, resolution) {
|
|||||||
return styles[feature.getGeometry().getType()];
|
return styles[feature.getGeometry().getType()];
|
||||||
};
|
};
|
||||||
|
|
||||||
var vectorSource = new ol.source.Vector();
|
var features = new ol.format.GeoJSON().readFeatures({
|
||||||
new ol.format.GeoJSON().readObject({
|
|
||||||
'type': 'FeatureCollection',
|
'type': 'FeatureCollection',
|
||||||
|
'crs': {
|
||||||
|
'type': 'name',
|
||||||
|
'properties': {
|
||||||
|
'name': 'EPSG:3857'
|
||||||
|
}
|
||||||
|
},
|
||||||
'features': [
|
'features': [
|
||||||
{
|
{
|
||||||
'type': 'Feature',
|
'type': 'Feature',
|
||||||
@@ -118,10 +123,12 @@ new ol.format.GeoJSON().readObject({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}, vectorSource.addFeature, vectorSource);
|
});
|
||||||
|
|
||||||
var vectorLayer = new ol.layer.Vector({
|
var vectorLayer = new ol.layer.Vector({
|
||||||
source: vectorSource,
|
source: new ol.source.Vector({
|
||||||
|
features: features
|
||||||
|
}),
|
||||||
styleFunction: styleFunction
|
styleFunction: styleFunction
|
||||||
});
|
});
|
||||||
var tmpLineFeature = new ol.Feature(
|
var tmpLineFeature = new ol.Feature(
|
||||||
|
|||||||
Reference in New Issue
Block a user