Class: GeoJSON

GeoJSON

Feature format for reading and writing data in the GeoJSON format.

new ol.format.GeoJSON(opt_options) experimental

Name Type Description
options optional

Options.

Name Type Description
defaultProjection ol.proj.ProjectionLike

Default projection.

geometryName string | undefined optional

Geometry name to use when creating features.

Extends

Methods

readFeature(source){ol.Feature} experimental

Read a feature from a GeoJSON Feature source. This method will throw an error if used with a FeatureCollection source.

Name Type Description
source ArrayBuffer | Document | Node | Object | string

Source.

Returns:
Feature.

readFeatures(source){Array.<ol.Feature>} experimental

Read all features from a GeoJSON source. Works with both Feature and FeatureCollection sources.

Name Type Description
source ArrayBuffer | Document | Node | Object | string

Source.

Returns:
Features.

readGeometry(source){ol.geom.Geometry} experimental

Read a geometry from a GeoJSON source.

Name Type Description
source ArrayBuffer | Document | Node | Object | string

Source.

Returns:
Geometry.

readProjection(object){ol.proj.Projection} experimental

Read the projection from the GeoJSON source file.

Name Type Description
object ArrayBuffer | Document | Node | Object | string

Source.

Returns:
Projection.

writeFeature(feature){ArrayBuffer|Node|Object|string} experimental

Encode a feature as a GeoJSON Feature object.

Name Type Description
feature ol.Feature

Feature.

Returns:
Result.

writeFeatures(features){ArrayBuffer|Node|Object|string} experimental

Encode an array of features as GeoJSON.

Name Type Description
features Array.<ol.Feature>

Features.

Returns:
Result.