Default JMap Web Actions

The JMap Web application template offers many actions to facilitate JMap Server interactions. This section will present some of them and how you can use them.

Note: The majority of actions require map state information as parameters. For the most part, these can be obtained using OpenLayers’s API.

All examples in this section refer to a deployment based on the The World project. The deployment covers the project’s complete extent and includes the following layers: “Base” and “Cities”. Refer yourself to the following screen shots in order to create a similar deployment.

'extractelements' Action

The extractelements action provides a list of a JMap layer’s elements.

The ‘geometry’ request type

The geometry request will extract elements that intersect or are contained within a supplied geometry.

Parameters

The following is the list of parameters that can be provided to the extractelements action.

Example

Performs an element extraction request for the “Cities” layer around the Scotland area.

$.ajax(JMap.app.ajaxDispatcher, {data: {

'action': 'extractelements',

'request': 'geometry',

'geometry': 'POLYGON((-6.378882 54.903806,-1.336158 54.903806,-1.336158 59.540037,-6.378882 59.540037,-6.378882 54.903806))',

'res': JMap.app.map.getResolution(),

'bbox': JMap.app.map.getExtent().toBBOX(),

'layers': 'Cities'

}}).success(function(data, textStatus, jqXHR) {

console.log(data);

});

Response

Each element’s ID, geometry (supplied as a WKT formatted string), attribute values, bounds and centered point are returned. The layer’s bound attributes are also included as well as their SQL type. An element’s attributes’s index corresponds to the layer’s attributes as configured in JMap Admin. If elements from many layers match the request parameters, an array of these object literals will be returned.

{

"layerId": 7,

"elementAttributes": [

{

"sqlType": 12,

"name": "CITY"

},

{

"sqlType": 12,

"name": "COUNTRY"

},

{

"sqlType": 12,

"name": "CAP"

},

{

"sqlType": 4,

"name": "POP2000"

}

],

"elements": [

{ "centeredPoint": {

"x": -1.3899999735879476,

"y": 54.910001831054686

},

"bounds": {

"x": -1.3899999735879476,

"width": 0,

"y": 54.910001831054686,

"height": 0

},

"attributeValues": [

"Sunderland",

"UK - England and Wales",

"0",

181100

],

"geometry": "POINT(-1.3899999735879476 54.910001831054686)",

"id": 622

},

{

"centeredPoint": {

"x": -4.2699998496102864,

"y": 55.87000091552734

},

"bounds": {

"x": -4.2699998496102864,

"width": 0,

"y": 55.87000091552734,

"height": 0

},

"attributeValues": [

"Glasgow",

"Scotland",

"0",

610700

],

"geometry": "POINT(-4.2699998496102864 55.87000091552734)",

"id": 624

},

{

"centeredPoint": {

"x": -3.2200001357125814,

"y": 55.949998931884764

},

"bounds": {

"x": -3.2200001357125814,

"width": 0,

"y": 55.949998931884764,

"height": 0

},

"attributeValues": [

"Edinburgh",

"UK - England and Wales",

"0",

382600

],

"geometry": "POINT(-3.2200001357125814 55.949998931884764)",

"id": 625

},

{

"centeredPoint": {

"x": -2.9999998686837728,

"y": 56.469999389648436

},

"bounds": {

"x": -2.9999998686837728,

"width": 0,

"y": 56.469999389648436,

"height": 0

},

"attributeValues": [

"Dundee",

"Scotland",

"0",

148900

],

"geometry": "POINT(-2.9999998686837728 56.469999389648436)",

"id": 627

},

{

"centeredPoint": {

"x": -2.1000000117349202,

"y": 57.14999969482422

},

"bounds": {

"x": -2.1000000117349202,

"width": 0,

"y": 57.14999969482422,

"height": 0

},

"attributeValues": [

"Aberdeen",

"Scotland",

"0",

188500

],

"geometry": "POINT(-2.1000000117349202 57.14999969482422)",

"id": 628

},

{

"centeredPoint": {

"x": -1.6000000117349202,

"y": 54.99999816894531

},

"bounds": {

"x": -1.6000000117349202,

"width": 0,

"y": 54.99999816894531,

"height": 0

},

"attributeValues": [

"Newcastle upon Tyne",

"UK - England and Wales",

"0",

980000

],

"geometry": "POINT(-1.6000000117349202 54.99999816894531)",

"id": 1899

}

]

}

‘layerinfo’ Action

The layerinfo action provides details regarding layers of the deployment’s associated project.

The ‘geteditablelayers’ request type

The geteditablelayers request will return layer various layer details on which the currently authenticated user may perform data editing tasks.

Parameters

This action does not require any parameters. Instead, it uses the current session information to perform this operation.

Example

$.ajax(JMap.app.ajaxDispatcher, {

data: {

'action': 'layerinfo',

'request': 'geteditablelayers'

}

}).success(function(data, textStatus, jqXHR) {

console.log(data);

});

Response

The server response exposes an array of editableLayers object literals. Each of the array’s objects contains the following keys:

forms are returned as an array of object literals. They have the following structure:

Example

This is an example of a geteditablelayers response. You may have different results. In any case, they should reflect the state of your configured permissions and forms.

{

"editableLayers": [

{

"offset": {

"x": 9.5367431640625e-7,

"y": -3.186320304870577 },

"permissions": 0,

"id": 4,

"fields": [

{

"name": "COUNTRY",

"serverDataType": 12

},

{

"name": "CONTINENT",

"serverDataType": 12

},

{

"name": "POP_1994",

"serverDataType": 8

},

{

"name": "POP_GRW_RT",

"serverDataType": 8

},

{

"name": "POP_0_14",

"serverDataType": 8

},

{

"name": "POP_15_64",

"serverDataType": 8

},

{

"name": "POP_65PLUS",

"serverDataType": 8

},

{

"name": "POP_AREA",

"serverDataType": 8

}

],

"idFieldName": "JMAP_ID",

"forms": []

},

{

"offset": {

"x": 0.56195068359375,

"y": 13.687942504882812

},

"permissions": 0,

"id": 6,

"fields": [

{

"name": "LAKE_NAME",

"serverDataType": 12

},

{

"name": "VOLUME_CKM",

"serverDataType": 8

},

{

"name": "AREA_SKM",

"serverDataType": 8

}

],

"idFieldName": "JMAP_ID",

"forms": []

},

{

"offset": {

"x": 20.934576233500025,

"y": 10.050437668683657

},

"permissions": 0,

"id": 5,

"fields": [],

"idFieldName": "JMAP_ID",

"forms": []

},

{

"offset": {

"x": 16.215000694478334,

"y": 16.463705277985326

},

"permissions": 0,

"id": 3,

"fields": [

{

"name": "HYD_NAME", "

serverDataType": 12

},

{

"name": "LENGTH_KM",

"serverDataType": 4

}

],

"idFieldName": "JMAP_ID",

"forms": []

},

{

"offset": {

"x": 31.452202349999993,

"y": -14.421794805000005

},

"permissions": 0,

"id": 2,

"fields": [

{

"name": "CONTINENTNAME",

"serverDataType": 12

}

],

"idFieldName": "JMAP_ID",

"forms": []

},

{

"offset": {

"x": 1.6169597031546061,

"y": 8.079999999999998

},

"permissions": 15,

"id": 7,

"fields": [

{

"name": "CITY",

"serverDataType": 12

},

{

"name": "COUNTRY",

"serverDataType": 12

},

{

"name": "CAP",

"serverDataType": 12

},

{

"name": "POP2000",

"serverDataType": 4

}

],

"idFieldName": "JMAP_ID",

"forms": [

{

"permissions": 0,

"name": "Form",

"json": "{\"formSections\":[{\"name\":\"Section 1\",\"nbRows\":3,\"fields\":[{\"$ATTRIBUTE_NAME\":\"CITY\",\"$ROW\":0,\"$MASKFORMATTER\":\"\",\"$COL\":0,\"$INPUT_TYPE\":\"$INPUT\",\"$MULTILINE\":false,\"$PREFIX\":\"CITY\",\"$ALIGNMENT\":\"LEFT\",\"$REQUIRED\":true,\"$MAX_NUMBER_CHARACTERS\":255,\"$COLSPAN\":1,\"$WIDTH\":100,\"$TOOLTIP\":\"\",\"$ATTRIBUTE_SQL_TYPE\":12,\"$READ_ONLY\":false}]}",

"id": 1,

"type": "LAYER_ATTRIBUTES_FORM",

"uidAttributeName": null

}

]

}

]}

‘loadformdata’ Action

The loadformdata action provides external form data for a requested layer element.

Parameters

loadformdata expects the following parameter:

Example

This example refers to another project for which external forms were configured.

var data = { elementId: 6, formId: 2, layerId: 1,

listFields: [],

"mapValues": {

"MOBILE_JMAP_ID": 6,

"MOBILE_JMAP_GEOMETRY": "POINT(-8189010.0 5701129.5)",

"AUTHOR": "jrhaddad",

"CREATION_TIME": 1415767972000,

"MODIFICATION_TIME": 1418400517000,

"ABR_CODE": "342",

"ABR_NAME": "ES34F",

"ABR_LOC_TYPE": "Arrêt bus",

"ABR_WHEEL_CHAIR": "Non accessible",

"ABR_DATE_INSP": null,

"ABR_STATUS": null

}

};

$.ajax(JMap.app.ajaxDispatcher, {data: {

'action': 'loadformdata',

'data': JSON.stringify(data)

}}).success(function(data, textStatus, jqXHR) {

console.log(data);

});

Response

The server responds by providing a two dimensional rows array of Javascript object literals representing field values. Each item in the rows array represents a row of data. Multiple rows are returned when obtaining data that was entered using a EXTERNAL_ATTRIBUTES_SUB_FORM type form.

The name of the form field, its value and the data’s SQL type are returned.

{

"rows": [

[

{

"name": "insp_abribus.id_inspection",

"value": 5,

"type": 4

},

{

"name": "insp_abribus.id_abribus",

"value": 6,

"type": 4

},

{

"name": "insp_abribus.date_inspection",

"value": 1415854800000,

"type": 93

},

{

"name": "insp_abribus.etat",

"value": "Bon état",

"type": 12

},

{

"name": "insp_abribus.observations",

"value": "Tout est ok",

"type": 12

}

]

]

}

Dernière mise à jour

K2 Geospatial 2024