Use ol.format.GeoJSON in geojson example

This commit is contained in:
Tom Payne
2013-12-04 17:20:47 +01:00
parent ecf9ace190
commit 0941f06c0b

View File

@@ -62,9 +62,14 @@ var styleFunction = function(feature, resolution) {
return styles[feature.getGeometry().getType()];
};
var vectorSource = new ol.source.Vector();
new ol.format.GeoJSON().readObject({
var features = new ol.format.GeoJSON().readFeatures({
'type': 'FeatureCollection',
'crs': {
'type': 'name',
'properties': {
'name': 'EPSG:3857'
}
},
'features': [
{
'type': 'Feature',
@@ -118,10 +123,12 @@ new ol.format.GeoJSON().readObject({
}
}
]
}, vectorSource.addFeature, vectorSource);
});
var vectorLayer = new ol.layer.Vector({
source: vectorSource,
source: new ol.source.Vector({
features: features
}),
styleFunction: styleFunction
});
var tmpLineFeature = new ol.Feature(