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