Use reader in GeoJSON example, instead of source
This commit is contained in:
+9
-8
@@ -3,8 +3,10 @@ goog.require('ol.RendererHint');
|
||||
goog.require('ol.View2D');
|
||||
goog.require('ol.layer.Tile');
|
||||
goog.require('ol.layer.Vector');
|
||||
goog.require('ol.source.GeoJSON');
|
||||
goog.require('ol.reader');
|
||||
goog.require('ol.reader.GeoJSON');
|
||||
goog.require('ol.source.OSM');
|
||||
goog.require('ol.source.Vector');
|
||||
goog.require('ol.style.DefaultStyleFunction');
|
||||
|
||||
|
||||
@@ -29,11 +31,9 @@ var styleFunction = function(feature) {
|
||||
}
|
||||
};
|
||||
|
||||
var geoJSONSource = new ol.source.GeoJSON(
|
||||
/** @type {ol.source.GeoJSONOptions} */ ({
|
||||
geoJSON: {
|
||||
var features = ol.reader.readAllFromObject(ol.reader.GeoJSON.readObject, {
|
||||
'type': 'FeatureCollection',
|
||||
features: [
|
||||
'features': [
|
||||
{
|
||||
'type': 'Feature',
|
||||
'geometry': {
|
||||
@@ -86,8 +86,7 @@ var geoJSONSource = new ol.source.GeoJSON(
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
var map = new ol.Map({
|
||||
layers: [
|
||||
@@ -95,7 +94,9 @@ var map = new ol.Map({
|
||||
source: new ol.source.OSM()
|
||||
}),
|
||||
new ol.layer.Vector({
|
||||
source: geoJSONSource,
|
||||
source: new ol.source.Vector({
|
||||
features: features
|
||||
}),
|
||||
styleFunction: styleFunction
|
||||
})
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user