Fix GeoJSON.readFeaturesFromObject
Only feature collections worked properly.
This commit is contained in:
@@ -398,7 +398,7 @@ ol.format.GeoJSON.prototype.readFeaturesFromObject = function(
|
||||
object, opt_options) {
|
||||
var geoJSONObject = /** @type {GeoJSONObject} */ (object);
|
||||
if (geoJSONObject.type == 'Feature') {
|
||||
return [this.readFeatureFromObject(object)];
|
||||
return [this.readFeatureFromObject(object, opt_options)];
|
||||
} else if (geoJSONObject.type == 'FeatureCollection') {
|
||||
var geoJSONFeatureCollection = /** @type {GeoJSONFeatureCollection} */
|
||||
(object);
|
||||
|
||||
@@ -174,6 +174,15 @@ describe('ol.format.GeoJSON', function() {
|
||||
expect(features[2].getGeometry()).to.be.an(ol.geom.Polygon);
|
||||
});
|
||||
|
||||
it('can read and transform a point', function() {
|
||||
var feature = format.readFeatures(pointGeoJSON, {
|
||||
featureProjection: 'EPSG:3857'
|
||||
});
|
||||
expect(feature[0].getGeometry()).to.be.an(ol.geom.Point);
|
||||
expect(feature[0].getGeometry().getCoordinates()).to.eql(
|
||||
ol.proj.transform([102.0, 0.5], 'EPSG:4326', 'EPSG:3857'));
|
||||
});
|
||||
|
||||
it('can read and transform a feature collection', function() {
|
||||
var features = format.readFeatures(featureCollectionGeoJSON, {
|
||||
featureProjection: 'EPSG:3857'
|
||||
|
||||
Reference in New Issue
Block a user