The VectorLayer object defines the basic properties required to construct a vector layer.

Attribute list

Attribute Type Description

layerType

string

[Required]

The VectorLayer type. Fixed constant: "VECTOR".

name

string

[Required]

The layer name.

visible

boolean

[Required]

The visibility of the layer.

opacity

number

[Optional]

The opacity of the layer. The maximum value is 1 and the minimum value is 0.

visibleScale

VisibleScale

[Optional]

Stores the visible scale range of the current layer.

dataSource

DataSource

[Required]

The datasource of the VectorLayer is one of the following five datasources:

 PortalDataSource, SampleData, RestData, UserData, RestMap

projection

string

[Required]

The projected coordinate system of the map. Optional value: EPSG or WKT universal coordinate system description standard.

featureType

string

[Required]

The feature type. Optional constants: "POINT", "LINE", "POLYGON".

xyField

object<srting>

[Required]

It consists of two sub-attributes "xField" and "yField", which respectively define the name of the field to which the X and Y coordinates of the point feature belong.

style

object

[Required]

The feature style, determined by the featureType attribute. If the featureType is "POINT", the point feature style must meet PointStyle ; if the featureType is "LINE", the line feature style must meet LineStyle; if the featureType is "POLYGON", the polygon feature style must meet PolygonStyle .

labelStyle

LabelStyle

[Optional]

Label style.

legendSetting

LegendSetting

[Optional]

Legend settings.

searchSetting

SearchSetting

[Optional]

Search settings.

enableFields

array<string>

[Required]

The fields displayed in attribute table

captions

object

[Optional]

The key is the field name, and the value is the user-defined string type field display name, for example: {"ADDRESS":"ADDRESS display name"}.

autoUpdateTime

number

[Optional]

The time for the layer data to be automatically refreshed, in milliseconds.

popupInfo

WithPopupInfo

[Optional]

Settings for the attribute pop-up window.

Example

  1. Construct a vector point layer that conforms to the WebMap specification.

 {   

     "layers": [

        {

            "layerType": "VECTOR",

            "name": "National provincial capitals",

            "visible": true,

            "featureType": "POINT",

            "xyField": {

                "xField": "X",

                "yField": "Y"

            },

            "projection": "EPSG:4326",

            "enableFields": [

                "X",

                "Y",

                "Province",

                "Capitals"

            ],

            "style": {

                "radius": 8,

                "fillColor": "#b8e986",

                "fillOpacity": 0.53,

                "strokeColor": "#50e3c2",

                "strokeWidth": 1,

                "strokeOpacity": 1,

                "offsetX": -0.7,

                "offsetY": 0.5,

                "type": "BASIC_POINT"

            },

            "dataSource": {

                "type": "PORTAL_DATA",

                "serverId": "1630324307",

                "accessType": "DIRECT"

            }

        }

    ],

 }

  1. Construct a vector polygon layer that conforms to the WebMap specification.

 {   

     "layers": [        

        {

            "layerType": "VECTOR",

            "name": "National provincial capitals",

            "visible": true,

            "featureType": "POLYGON",

            "projection": "EPSG:4326",

            "enableFields": [

                "X",

                "Y",

                "Province",

                "Capitals"

            ],

            "style": {

                "fillColor": "#826DBA",

                "fillOpacity": 0.9,

                "strokeColor": "#ffffff",

                "strokeWidth": 1,

                "strokeOpacity": 1,

                "lineDash": "solid",

                "type": "POLYGON"

            },

            "dataSource": {

                "type": "PORTAL_DATA",

                "serverId": "1195851180",

                "accessType": "DIRECT",

                "administrativeInfo": {

                    "divisionType": "Province",

                    "divisionField": "Province"

                 }

            }

        }

     ],

 }

  1. Construct a vector line layer that conforms to the WebMap specification.

{

    "layers": [

        {

            "layerType": "VECTOR",

            "name": "Beijing subway traffic lines",

            "visible": true,

            "featureType": "LINE",

            "projection": "EPSG:4326",

            "enableFields": [

                "Standard name"

            ],

            "style": [

                {

                    "strokeWidth": 1,

                    "lineDash": "solid",

                    "strokeColor": "#d69c08",

                    "strokeOpacity": 1,

                    "type": "LINE"

                },

                {

                    "strokeColor": "#4CC8A3",

                    "strokeWidth": 2,

                    "strokeOpacity": 1,

                    "lineDash": "dash",

                    "type": "LINE"

                }

            ],

            "dataSource": {

                "type": "SAMPLE_DATA",

                "name": "BeijingSubwayLine"

            }

        }

    ],

}