Class: GeoJSON

SuperMap.Format.GeoJSON

GeoJSON read and write. Create a GeoJSON parser using SuperMap.Format.GeoJSON constructor.

new SuperMap.Format.GeoJSON(options)

GeoJSON.js, line 16
Name Type Description
options Object optional

parameter.

Name Type Default Description
indent string " " optional

Used to format the output, the indent string is used once for each indentation.

space string " " optional

Used to format the output, the space string is added after the ":" of the name-value pair.

newline string "\n" optional

Used to format the output, the newline string is used at each end of the name value pair or array item.

level number 0 optional

Used to format the output, indicating the indentation level.

pretty boolean false optional

Whether to use extra space to control the structure when serializing. Used in the write method.

nativeJSON boolean optional

A listener object that needs to be registered.

ignoreExtraDims boolean true optional

Ignore geometric features with dimensions greater than 2.

Extends

Members

dataObject

When the keepData attribute is set to true, This is the string that is passed to the read operation to be parsed.

ignoreExtraDimsboolean

Ignore geometry with more than 2 dimensions.

Default Value:
true

indentstring

Format output. For every indent, the indent string will use one time.

Default Value:
" "

keepDataObject

Keep a reference to the data that is read recently (through the attribute). The default value is false

levelinteger

use formatted output, the indentation level is expressed.

nativeJSONboolean

Determine whether browsers are native to support JSON format data.

newlinestring

Format output. newline string will be used for each name value pair or the last number of array.

Default Value:
'\n'

prettyboolean

Whether to use words wrap and indent to control the output.

serialize

A method of providing a number of type objects to a JSON string.

spacestring

Format output. space string wil be added after the name value pair ":".

Default Value:
" "

Methods

inherited destroy()

Format.js, line 36

Disposes the resource. The property that references resource is set to null.

fromGeoJSON(json, type, filter){Object}

GeoJSON.js, line 455

Convert a GeoJSON object or a GeoJSON object string to an iServer Feature JSON.

Name Type Default Description
json GeoJSONObject

GeoJSON object.

type string 'FeaureCollection' optional

An optional string that determines the format of the output. The supported values are: "Geometry", "Feature", and "FeatureCollection" if this value is null.

filter function

This function is called for each key-value pair at each level in the object to produce a result. Each value is replaced by the result of the filter function. This function can be used to convert some objects into corresponding objects of a class, or to convert a date string into a Date object.

Version:
  • 9.1.1
Returns:
Type Description
Object iServer Feature JSON。

read(json, filter, type){Object}

GeoJSON.js, line 364

Convert a GeoJSON object or a GeoJSON object string to a SuperMap Feature object.

Name Type Default Description
json GeoJSONObject

GeoJSON object.

filter function

Optional string. It determines the output format. The supported values are "Geometry","Feature" and "FeatureCollection", If this value is null, it will use default value "FeaureCollection".

type string 'FeaureCollection' optional

An optional string that determines the format of the output. The supported values are: "Geometry", "Feature", and "FeatureCollection" if this value is null.

Returns:
Type Description
Object The return value depends on type parameter value.
If type is "FeatureCollection"(Default value), the return value will be SuperMap.Feature.Vector array.
If type is "Geometry", the input json object must be a unique geometry, and the return value is SuperMap.Feature.Geometry.
If type is "Feature", the input json object is a feature and the return value is SuperMap.Feature.Vector.

toGeoJSON(obj){GeoJSONObject}

GeoJSON.js, line 468

Convert an iServer Feature JSON object to a GeoJSON object.

Name Type Description
obj Object

iServer Feature JSON。

Version:
  • 9.1.1
Returns:
Type Description
GeoJSONObject GeoJSON object.

write(obj, pretty){GeoJSONObject}

GeoJSON.js, line 445

iServer's Geometry JSON object to a GeoJSON object string.

Name Type Default Description
obj Object

iServer's Geometry JSON object.

pretty boolean false optional

Whether to use line feed and indentation to control the output.

Returns:
Type Description
GeoJSONObject A GeoJSON string that represents the input geometry object, feature object, or array of feature objects.