Use ol.source.GeoJSON in geojson example
This commit is contained in:
+7
-7
@@ -2,14 +2,13 @@ goog.require('ol.Feature');
|
|||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.RendererHint');
|
goog.require('ol.RendererHint');
|
||||||
goog.require('ol.View2D');
|
goog.require('ol.View2D');
|
||||||
goog.require('ol.format.GeoJSON');
|
|
||||||
goog.require('ol.geom.LineString');
|
goog.require('ol.geom.LineString');
|
||||||
goog.require('ol.geom.Point');
|
goog.require('ol.geom.Point');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
goog.require('ol.layer.Vector');
|
goog.require('ol.layer.Vector');
|
||||||
goog.require('ol.shape');
|
goog.require('ol.shape');
|
||||||
|
goog.require('ol.source.GeoJSON');
|
||||||
goog.require('ol.source.OSM');
|
goog.require('ol.source.OSM');
|
||||||
goog.require('ol.source.Vector');
|
|
||||||
goog.require('ol.style.Fill');
|
goog.require('ol.style.Fill');
|
||||||
goog.require('ol.style.Stroke');
|
goog.require('ol.style.Stroke');
|
||||||
goog.require('ol.style.Style');
|
goog.require('ol.style.Style');
|
||||||
@@ -62,7 +61,9 @@ var styleFunction = function(feature, resolution) {
|
|||||||
return styles[feature.getGeometry().getType()];
|
return styles[feature.getGeometry().getType()];
|
||||||
};
|
};
|
||||||
|
|
||||||
var features = new ol.format.GeoJSON().readFeatures({
|
var vectorSource = new ol.source.GeoJSON(
|
||||||
|
/** @type {ol.source.GeoJSONOptions} */ ({
|
||||||
|
object: {
|
||||||
'type': 'FeatureCollection',
|
'type': 'FeatureCollection',
|
||||||
'crs': {
|
'crs': {
|
||||||
'type': 'name',
|
'type': 'name',
|
||||||
@@ -123,12 +124,11 @@ var features = new ol.format.GeoJSON().readFeatures({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
var vectorLayer = new ol.layer.Vector({
|
var vectorLayer = new ol.layer.Vector({
|
||||||
source: new ol.source.Vector({
|
source: vectorSource,
|
||||||
features: features
|
|
||||||
}),
|
|
||||||
styleFunction: styleFunction
|
styleFunction: styleFunction
|
||||||
});
|
});
|
||||||
var tmpLineFeature = new ol.Feature(
|
var tmpLineFeature = new ol.Feature(
|
||||||
|
|||||||
Reference in New Issue
Block a user