From 0941f06c0b3d1e93c6584fb5ac4806c7972f4b53 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Wed, 4 Dec 2013 17:20:47 +0100 Subject: [PATCH] Use ol.format.GeoJSON in geojson example --- examples/geojson.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/examples/geojson.js b/examples/geojson.js index 8ab63eedbb..e42e73efac 100644 --- a/examples/geojson.js +++ b/examples/geojson.js @@ -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(