- Properties:
- Methods:
- addField(options)
- updateField(field_id, options)
- getFields()
- getFieldStats(field_id, options)
- getFieldUniqueValues(field_id, options)
- getFieldUniqueValuesCount(field_id, options)
- deleteField(field_id)
- deleteFields(field_ids)
- getSettings()
- updateSettings(options)
- getTilejson()
- getFeature(feature_id)
- getFeatures(option)
- createFeature(geojson)
- deleteFeature(feature_id)
- deleteFeatures(feature_ids)
- updateFeature(feature_id, geojson)
- updateFeatureGeometry(feature_id, options)
- updateFeatureProps(feature_id, options)
- updateFeaturePropsAndGeometry(feature_id, properties_options, geometry_options)
- seedCache(options)
- getCacheSize()
- clearCache()
- importFile(options)
- export(options)
- calculateField(options)
Tip: After you access the vector layer object, the following methods and properties are applicable on the vector layer.
Properties:
uuid
Returns the universally unique identifier (UUID) of the vector layer.
Returns:
uuid: Returns uuid string.
Example:
const vectorLayerUuid = vectorLayer.uuid;
name
Returns the name of the vector layer.
Returns:
String: Returns vector layer name.
Example:
const vectorLayerName = vectorLayer.name;
display_name
Returns the display name of the vector layer.
Returns:
String: Returns vector layer display name.
Example:
const vectorLayerDisplayName = vectorLayer.display_name;
description
Returns the description of the vector layer.
Returns:
String: Returns vector layer description.
Example:
const vectorLayerDescription = vectorLayer.description;
created_at
Returns the time and date that the vector layer was created.
Returns:
Date: Returns vector layer created time.
Example:
const vectorLayerCreatedTime = vectorLayer.created_at;
last_edit_at
Returns the time and date that the vector layer is updated.
Returns:
Date: Returns vector layer updated time.
Example:
const vectorLayerModifiedTime = vectorLayer.last_edit_at;
is_shared
Indicates whether the vector layer is shared or not.
Returns:
Boolean: If true, vector layer is shared.
Example:
const isShared = vectorLayer.is_shared;
is_view
Indicates whether the vector layer is vector layer view or not.
Returns:
Boolean: If true, vector layer is vector layer view.
Example:
const isView = vectorLayer.is_view;
has_z
Indicates whether the vector layer geometry is 3D or not.
Returns:
Boolean: If true, vector layer geometry is 3D and has z value.
Example:
const hasZ = vectorLayer.has_z;
id
Returns the vector layer id.
Returns:
Number: Returns vector layer id.
Example:
const vectorLayerId = vectorLayer.id;
owner_id
Returns the user ID that the vector layer belongs to.
Returns:
Number: Returns vector layer owner id.
Example:
const vectorLayerOwnerId = vectorLayer.owner_id;
layer_type
Returns the type of geometry of the vector layer.
Returns:
String: Returns geometry type of vector layer.
Example:
const vectorLayerType = vectorLayer.layer_type;
layer_settings
Returns the vector layer settings. This parameter has a value if include_settings is true at the time of getting vector layer.
Returns:
Object: Returns settings object.
Example:
const layerSettings = vectorLayer.layer_settings;
extent
Returns the coordinates of the vector layer extent in the Web Mercator coordinate system.
Returns:
Array: Returns an array contains [southwest x, southwest y, northeast x, northeast y].
Example:
const vectorLayerExtent = vectorLayer.extent;
feature_count
Returns the number of features in the vector layer.
Returns:
Number: Returns count of features.
Example:
const featureCount = vectorLayer.feature_count;
Methods:
addField(options)
Adds new field to the vector layer.
Parameters:
options (Object)
Name | Description |
---|---|
options.name
String
|
Name of new field. |
options.display_name
String?
|
Display name of new field. |
options.description
String?
|
Description of field. |
options.datatype
String
|
Choices are: ‘String’ | ‘Integer’ | ‘Long’ | ‘Float’ | ‘Date’ | ‘Time’ | ‘DateTime’ |
options.width
Number
|
Field length |
Returns:
Object: Returns field object.
Example:
const newField = await vectorLayer.addField({ 'name': 'string', 'display_name': 'string', 'description': 'string', 'datatype': 'String', 'width': 10 })
updateField(field_id, options)
Updates the existing field of vector layer.
Parameters:
field_id is the id of an available field.
options (Object)
Name | Description |
---|---|
options.name
String
|
Name of field. |
options.display_name
String?
|
Display name of field. |
options.description
String?
|
Description of field. |
Returns:
Object: Returns field object.
Example:
const field = await vectorLayer.updateField(10,{ 'name': 'string', 'display_name': 'string', 'description': 'string' })
getFields()
Returns the vector layer fields.
Returns:
Array: Returns an array of fields.
Example:
const allFields = await vectorLayer.getFields();
getFieldStats(field_id, options)
Returns the statistical parameters of the field, including the minimum value, the maximum value, and the average.
Parameters:
field_id is the id of an available field.
options (Object)
Name | Description |
---|---|
options.func_type
String
|
choices are ‘min’ | ‘max’ | ‘avg’. |
Returns:
String: Returns field statistic value.
Example:
const fieldStat = await vectorLayer.getFieldStats(10,{func_type:'avg'});
getFieldUniqueValues(field_id, options)
Returns the unique values of the field.
Parameters:
field_id is the id of an available field.
options (Object)
Name | Description |
---|---|
options.exclude_null
Boolean
defult: false
|
If true, null values skipped. |
options.skip
Number?
Default: 0
|
Number of skipped unique values. |
options.limit
Number?
Default:50
|
Maximum number for result unique values.. |
Returns:
Array: Returns an array of unique values.
Example:
const fieldUniqueValues = await vectorLayer.getFieldUniqueValues(10);
getFieldUniqueValuesCount(field_id, options)
Returns the number of unique values of the field.
Parameters:
field_id is the id of an available field.
options (Object)
Name | Description |
---|---|
options.exclude_null
Boolean
defult: false
|
If true, null values skipped. |
Returns:
Number: Returns count of unique values.
Example:
const fieldUniqueValuesCount = await vectorLayer.getFieldUniqueValuesCount(10);
deleteField(field_id)
Deletes the existing field.
Parameters:
field_id is the id of an available field.
Returns:
String: Returns a message that shows deleting was successful or not. Null message means deleting was successful.
Example:
const result = await vectorLayer.deleteField(2);
deleteFields(field_ids)
Deletes the existing fields.
Parameters:
field_ids is an array of ids of available fields.
Returns:
String: Returns a message that shows deleting was successful or not. Null message means deleting was successful.
Example:
const result = await vectorLayer.deleteFields([2,125]);
getSettings()
Returns the vector layer settings.
Returns:
Object: Returns settings object.
Example:
const layerSettings = await vectorLayer.getSettings();
updateSettings(options)
Updates the vector layer settings.
Parameters:
options (Object)
Name | Description |
---|---|
options.general_settings
String
|
e.g. { ‘title_field’: ‘name’} |
options.edit_settings
String?
|
e.g. { ‘editable’: true, ‘edit_geometry’: true, ‘editable_attributes’: ‘[ALL]’, ‘allow_insert’: true, ‘allow_delete’: true } |
options.tile_settings
String?
|
e.g. { ‘min_zoom’: 0, ‘max_zoom’: 22, ‘max_features’: 65536, ‘filter_features’: true, ‘fields’: [ ‘id’ ], ‘use_cache’: true, ‘cache_until_zoom’: 17 } |
Returns:
Object: Returns settings object.
Example:
const layerSettings = await vectorLayer.updateSettings({ 'general_settings': { 'title_field': 'name' }, 'edit_settings': { 'editable': true, 'edit_geometry': true, 'editable_attributes': '[ALL]', 'allow_insert': true, 'allow_delete': true }, 'tile_settings': { 'min_zoom': 0, 'max_zoom': 22, 'max_features': 65536, 'filter_features': true, 'fields': [ 'id' ], 'use_cache': true, 'cache_until_zoom': 17 } });
getTilejson()
Returns vector layer tile information such as tile access address.
Returns:
Object: Returns an object that contains vector layer tiles information.
Example:
const layerTilejson = await vectorLayer.getTilejson();
getFeature(feature_id)
Returns the GeoJSON of the desired feature of the vector layer.
Parameters:
feature_id is the id of an available feature.
Returns:
Geojson: Returns geojson of feature.
Example:
const feature = await vectorLayer.getFeature(1);
getFeatures(option)
Returns the GeoJSON of the desired features of the vector layer.
Parameters:
options (Object)
Name | Description |
---|---|
options.f
String?
Default: ‘json’
|
Output format. Choices are: ‘json’ | ‘topojson’ | ‘html’ |
options.quant_factor
Number?
Default: 1000000
|
Quantization factor. This parameter is only used by topojson encoder and is ignored for other formats. Higher quantizaion value means higher geometry precision. |
options.skip
Number?
Default: 0
|
Number of skipped features. |
options.limit
Number?
Default:100
|
Maximum number for result features. |
options.search
String
|
search term for keyword-based searching among search_fields or all textual fields if search_fields does not have value. NOTE: if q param is defined this param will be ignored. |
options.search_fields
String?
|
Comma separated list of fields for searching |
options.skip_geometry
Boolean?
Default: false
|
If true, output result does not have geometry. |
options.return_count
Boolean?
Default: false
|
if true, returns only the number of features that satisfy conditions. |
options.feature_ids
String?
|
Comma separated list of feature ids which should be filtered. |
options.select_fields
String?
Default: [ALL]
|
Comma separated field names which should be included to the result. |
options.skip_fields
String?
|
Comma separated field names which should be excluded from the result. |
options.out_srid
String?
Default: 3857
|
Srid (epsg code) of result features. e.g. 4326 |
options.order_by
String?
|
Comma separated list of fields for sorting results [field1 A|D, field2 A|D, …]. e.g. name A, length D NOTE: “A” denotes ascending order and “D” denotes descending order. |
options.q
String
|
Query filter based on OGC CQL standard. e.g. Name LIKE ‘%GIS%’ AND INTERSECTS(geometry, ‘SRID=3857;POLYGON((4901948 2885079, 7049893 2885079, 7049893 4833901, 4901948 4833901, 4901948 2885079))’) |
options.bbox
Array?
|
e.g. [50.275, 35.1195, 51.4459, 36.0416] |
options.bbox_srid
Number?
Default: 3857
|
Srid (epsg code) of bbox. e.g. 4326. |
options.page
Number?
Default:1
|
The minimum number of pages is 1. |
options.page_size
Number?
Default:10
|
The minimum number of features on each page is 1. |
Returns:
Geojson: Returns geojson of features.
Example:
const features = await vectorLayer.getFeatures({ f: "json", q: `id=1`, out_srid: 4326, select_fields: ["id"] })
createFeature(geojson)
Creates new feature.
Returns:
Geojson: Returns created feature geojson.
Example:
const newFeature = await vectorLayer.createFeature({ 'type': 'Feature', 'geometry': { 'type': 'Point', 'coordinates': [5610214, 4215675], }, 'properties': {'name':'tehran'} })
deleteFeature(feature_id)
Deletes the desired feature from the vector layer.
Parameters:
feature_id is the id of an available feature.
Returns:
String: Returns a message that shows deleting was successful or not. Null message means deleting was successful.
Example:
const result = await vectorLayer.deleteFeature(10);
deleteFeatures(feature_ids)
Deletes the desired features of the vector layer.
Parameters:
feature_ids is a comma separated list of ids of features.
Returns:
String: Returns a message that shows deleting was successful or not. Null message means deleting was successful.
Example:
const result = await vectorLayer.deleteFeatures([10,20]);
updateFeature(feature_id, geojson)
Updates the desired feature of the vector layer.
Parameters:
feature_id is the id of an available feature.
Returns:
Geojson: Returns feature geojson.
Example:
const feature = await vectorLayer.updateFeature(10,{ 'type': 'Feature', 'geometry': { 'type': 'Point', 'coordinates': [5610214, 4215675], }, 'properties' = {'name':'tehran'} })
updateFeatureGeometry(feature_id, options)
Updates the desired feature geometry.
Parameters:
feature_id is the id of an available feature.
options (Object)
Name | Description |
---|---|
options.type
String
|
Type of geometry. |
options.coordinates
String?
|
Array of coordinates. |
Returns:
Geojson: Returns feature geojson.
Example:
const feature = await vectorLayer.updateFeatureGeometry(10,{ 'type': 'Point', 'coordinates': [5610214, 4215675], })
updateFeatureProps(feature_id, options)
Updates the desired feature attributes.
Parameters:
feature_id is the id of an available feature.
options (Object): Object of fields and values.
Returns:
Geojson: Returns feature geojson.
Example:
const feature = await vectorLayer.updateFeatureProps(10,{ 'name': 'tehran' })
updateFeaturePropsAndGeometry(feature_id, properties_options, geometry_options)
Updates the desired feature geometry and attributes.
Parameters:
feature_id is the id of an available feature.
properties_options (Object): Object of fields and values.
geometry_options (Object)
Name | Description |
---|---|
options.type
String
|
Type of geometry. |
options.coordinates
String
|
Array of coordinates. |
Returns:
Geojson: Returns feature geojson.
Example:
const feature = await vectorLayer.updateFeaturePropsAndGeometry(10, {'name': 'tehran'}, {'type': 'Point', 'coordinates': [5610214, 4215675]} )
seedCache(options)
Generates and stores tiles for the existing vector layer. See generating and managing vector layers for more guidance.
Parameters:
options (Object)
Name | Description |
---|---|
options.from_zoom
Number
|
from_zoom parameter is between 0 and 22. |
options.to_zoom
Number
|
to_zoom parameter is between 0 and 22. |
options.ignore_cache
Boolean
default: true
|
If true, ignore previous cache. |
options.workers
Number
|
Number of cpu cores. |
options.user_id
Number?
|
If the admin wants to builds cache for a vector layer of a certain user, this parameter determines which user is the target user. |
Returns:
Object: Returns task id to manage task.
Example:
const taskId = await vectorLayer.seedCache({ 'from_zoom': 0, 'to_zoom': 2, 'ignore_cache': true, 'workers': 1, 'user_id': 2 })
getCacheSize()
Returns the size of tiles generated and stored for vector layer in bytes.
Returns:
Number: Returns tiles size in byte.
Example:
const tilesSize = await vectorLayer.getCacheSize();
clearCache()
Removes generated tiles for the desired vector layer.
Returns:
String: Returns a message that shows clearing was successful or not. Null message means clearing was successful.
Example:
const result = await vectorLayer.clearCache();
importFile(options)
Imports file data to the vector layer.
Parameters:
options (FormData)
Name | Description |
---|---|
file_uuid
String
|
Universally unique identifier (UUID) of the file that is published in the geobox portal. |
file_encoding
String
Deafult: ‘utf-8’
|
Encoding of the file. e.g. ‘utf-8’ |
input_srid
Number
Deafult: 3857
|
srid of the input layer |
input_layer
String
|
Name of the layer that you want to import. |
input_dataset
String
|
Name of the dataset that you want to import layer from. |
input_geom_type
String
|
If there are multiple geometry type in the dataset, select the geometry type that you want to import. Choices are: ‘POINT’| ‘LINESTRING’| ‘POLYGON’| ‘MULTIPOINT’| ‘MULTILINESTRING’| ‘MULTIPOLYGON’| ‘POINTZ’| ‘LINESTRINGZ’| ‘POLYGONZ’| ‘MULTIPOINTZ’| ‘MULTILINESTRINGZ’| ‘MULTIPOLYGONZ’. |
report_errors
Boolean
Default: false
|
If true, errors will be reported. |
user_id
Number?
|
If the admin wants to imports file to a vector layer of a certain user, this parameter determines which user is the target user. |
Returns:
Object: Returns task id to manage task.
Example:
First, create a FormData. Then add the values.
let formData = new FormData(); formData.append('file_uuid', '4f9f3e4b-4dc1-469b-83ab-00ae00f02581'); formData.append('file_encoding', 'utf-8'); formData.append('input_srid', 3857); formData.append('input_layer', 'province'); formData.append('input_geom_type', 'POLYGON');
const result = await vectorLayer.importFile(formData);
export(options)
Exports the vector layer to different formats.
Parameters:
options (FormData)
Name | Description |
---|---|
out_format
String
|
Choices are: ‘Shapefile‘ | ‘GPKG’ | ‘GeoJSON’ | ‘CSV’ | ‘KML’ | ‘DXF’. |
out_srid
Number
Deafult: 3857
|
srid of output layer. |
q
String?
|
Query filter based on OGC CQL standard. e.g. “field1 LIKE ‘%GIS%’ AND created_at > ‘2021-01-01′” |
bbox
Array?
|
[southwest x, southwest y, northeast x, northeast y] |
bbox_srid
Number
Deafult: 3857
|
srid of bounding box |
feature_ids
Array?
|
Comma separated list of ids for searching |
fields
Array?
|
Comma separated list of fields for searching |
zipped
Boolean
Default: false
|
If true, the output is compressed. |
run_async
Boolean
Default: true
|
If true, the process will be doing as a task, otherwise object will be returned directly. |
Returns:
Object: Returns task id to manage task.
Example:
First, create a FormData. Then add the values.
let formData = new FormData(); formData.append('out_format', 'Shapefile'); formData.append('out_srid', 4326); formData.append('zipped', true);
const outputResult = await vectorLayer.export(formData);
After completing the desired task, use getTask to access the task information, which also includes the file download link.
calculateField(options)
Calculates new values for a field.
Parameters:
options (FormData)
Name | Description |
---|---|
target_field
String
|
Name of target field |
expression
String
|
Formula that calculates new values of the field. |
q
String?
|
Query filter based on OGC CQL standard. e.g. “field1 LIKE ‘%GIS%’ AND created_at > ‘2021-01-01′” |
bbox
Array?
|
[southwest x, southwest y, northeast x, northeast y] |
bbox_srid
Number
Deafult: 3857
|
srid of bounding box |
feature_ids
Array?
|
Comma separated list of ids for filtering features |
run_async
Boolean
Default: true
|
If true, the process will be doing as a task, otherwise object will be returned directly. |
user_id
Number?
|
If the admin wants to calculates field for a vector layer of a certain user, this parameter determines which user is the target user. |
Returns:
Object: Returns task id to manage task.
Example:
First, create a FormData. Then add the values.
let formData = new FormData(); formData.append('target_field', 'area'); formData.append('expression', 'length'); formData.append('run_async', true);
const outputResult = await vectorLayer.calculateField(formData);