OpenLayers. Format. GeoJSON

Read and write GeoJSON.  Create a new parser with the OpenLayers.Format.GeoJSON constructor.

Inherits from

Summary
OpenLayers. Format. GeoJSONRead and write GeoJSON.
Properties
ignoreExtraDims{Boolean} Ignore dimensions higher than 2 when reading geometry coordinates.
Constructor
OpenLayers. Format. GeoJSONCreate a new parser for GeoJSON.
Functions
readDeserialize a GeoJSON string.
writeSerialize a feature, geometry, array of features into a GeoJSON string.

Properties

ignoreExtraDims

{Boolean} Ignore dimensions higher than 2 when reading geometry coordinates.

Constructor

OpenLayers. Format. GeoJSON

Create a new parser for GeoJSON.

Parameters

options{Object} An optional object whose properties will be set on this instance.

Functions

read

read: function(json,
type,
filter)

Deserialize a GeoJSON string.

Parameters

json{String} A GeoJSON string
type{String} Optional string that determines the structure of the output.  Supported values are “Geometry”, “Feature”, and “FeatureCollection”.  If absent or null, a default of “FeatureCollection” is assumed.
filter{Function} A function which will be called for every key and value at every level of the final result.  Each value will be replaced by the result of the filter function.  This can be used to reform generic objects into instances of classes, or to transform date strings into Date objects.

Returns

{Object} The return depends on the value of the type argument.  If type is “FeatureCollection” (the default), the return will be an array of OpenLayers.Feature.Vector.  If type is “Geometry”, the input json must represent a single geometry, and the return will be an OpenLayers.Geometry.  If type is “Feature”, the input json must represent a single feature, and the return will be an OpenLayers.Feature.Vector.

write

write: function(obj,
pretty)

Serialize a feature, geometry, array of features into a GeoJSON string.

Parameters

obj{Object} An OpenLayers.Feature.Vector, OpenLayers.Geometry, or an array of features.
pretty{Boolean} Structure the output with newlines and indentation.  Default is false.

Returns

{String} The GeoJSON string representation of the input geometry, features, or array of features.

read: function(json,
type,
filter)
Deserialize a GeoJSON string.
write: function(obj,
pretty)
Serialize a feature, geometry, array of features into a GeoJSON string.
Create a new parser for GeoJSON.
A parser to read/write JSON safely.
Vector features use the OpenLayers.Geometry classes as geometry description.
A Geometry is a description of a geographic object.
Close