Class: GeoJSON

SuperMap.Format.GeoJSON

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

new SuperMap.Format.GeoJSON()

GeoJSON.js, line 16

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.

indentstring

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

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'

optionsObject

The optional parameters.

parseCoordsObject

An attribute name corresponds to an object of the geometric type of the GeoJSON object. Actually each attribute is a method that is actually used for parsing.

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 ":".

Methods

SuperMap.Format.GeoJSON.createCRSObject(object){GeoJSONObject}

GeoJSON.js, line 580

A coordinate reference object is created from a feature object.

Name Type Description
object SuperMap.Feature.Vector

a feature object.

Returns:
Type Description
GeoJSONObject An object that can be used as an CRS attribute of a GeoJSON object.

SuperMap.Format.GeoJSON.toGeoLinem()

GeoJSON.js, line 727

The geometric object of the route line of the server is transformed into a geometric object.

SuperMap.Format.GeoJSON.toGeoPoint()

GeoJSON.js, line 667

Converting the server's point geometric objects into geometric objects.

SuperMap.Format.GeoJSON.toGeoPoint()

GeoJSON.js, line 690

The linear geometric object of the server is converted into a geometric object.

SuperMap.Format.GeoJSON.toGeoRectangle()

GeoJSON.js, line 809

The geometric object of the server is transformed into a geometric object.

SuperMap.Format.GeoJSON.toGeoRegion()

GeoJSON.js, line 761

The surface geometry object of the server is transformed into a geometric object.

SuperMap.Format.GeoJSON.write(obj, pretty){string}

GeoJSON.js, line 541

Serializes a feature, a geometry and feature array into a GeoJSON string.

Name Type Default Description
obj GeoJSONObject

a SuperMap.Feature.Vector object,a SuperMap.Geometry object and a feature object array.

pretty boolean false optional

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

Returns:
Type Description
string A GeoJSON string, which represents the input geometry, feature object and feature array.

inherited destroy()

Format.js, line 39

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

isValidType(){boolean}

GeoJSON.js, line 436

Check whether a GeoJSON object is in conformity with the given type.

Returns:
Type Description
boolean Whether the GeoJSON object is a legitimate object of a given type.

parseFeature(obj){SuperMap.Feature.Vector}

GeoJSON.js, line 472

Transform the feature on a GeoJSON object to SuperMap.Feature.Vector object.

Name Type Description
obj GeoJSONObject

Create an object from the GeoJSON object.

Returns:
Type Description
SuperMap.Feature.Vector One feature.

parseGeometry(obj){SuperMap.Geometry}

GeoJSON.js, line 499

Transform the geometry feature on the GeoJSON object to SuperMap.Geometry object.

Name Type Description
obj GeoJSONObject

Create an object from the GeoJSON object.

Returns:
Type Description
SuperMap.Geometry One geometry feature

read(json, filter, type){Object}

GeoJSON.js, line 354

Deserializes a GeoJSON string.

Name Type Default Description
json GeoJSONObject

GeoJSON string.

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.

inherited write(value, pretty){string}

JSON.js, line 233

Serialize an object to a string that conforms to the JSON format.

Name Type Description
value object | string | Array | number | boolean

object, array, string, number, boolean that needs to be serialized.

pretty boolean optional

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

Returns:
Type Description
string String conforming to JSON format

inherited writeIndent(){string}

JSON.js, line 257

A indentation string is output according to the indentation level.

Returns:
Type Description
string An appropriate indentation string.

inherited writeNewline(){string}

JSON.js, line 272

A string representing a new line is output in the format of formatted output mode.

Returns:
Type Description
string A string representing a new line.

inherited writeSpace(){string}

JSON.js, line 281

Output a string representing a space in the format of formatted output mode.

Returns:
Type Description
string A space.