API
Map related functions
This functions are used to manipulate map.
addMapInteraction
To add interaction to the map pass options to the addMapInteraction function. This function also takes
optional callback function as a second parameter, but
only used for select | draw interactions. For other
interactions it will be ignored.
Options
-
type- Type of the interaction. Supported interaction types areselect | draw | modify | translate | snap | modifyAndTranslate. Snap interaction automatically added ondraw | modify | split | modifyAndTranslateoperations.modifyAndTranslateinteraction is a combination ofmodifyandtranslateinteractions. Whenmodify | modifyAndTranslateinteractions are added you can remove vertex. To remove vertex, select it by clicking on it then clickRight mouse buttonon it. -
geometryType- Type of the geometry. Supported geometry types arePoint | PolygonThis parameter is required only fordrawinteraction. For other interactions it will be ignored if passed.
Callback Function
-
callback- Optional parameter. Function to be called back when selecting feature will be triggered or drawing feature will be end. This function only used forselect | drawinteraction. For other interactions it will be ignored.
Example #1
var options = {
type: 'select'
};
function callback() {
// Body of the callback function ...
}
GisTools.addMapInteraction({options: options}, callback);
Example #2
var options = {
type: 'draw',
geometryType: 'Point'
};
function callback() {
// Body of the callback function ...
}
GisTools.addMapInteraction({options: options}, callback);
addSplitter
To add split line to the map use addSplitter function.
Example
GisTools.addSplitter();
calculateGeometryArea
To calculate area of the geometry pass options to the calculateGeometryArea
function. Returns value as a Ha
unit.
Options
-
geometry- The geometry, which area will be calculated.Geometry structure
-
type- Type of the geometry. -
coordinates- Coordinates of the geometry.
-
Example
var options = {
geometry: {
type: 'Polygon',
coordinates: [
[
[49.853298962116234,40.37223182544446],
[49.8535457253456,40.37183130860711],
[49.8535457253456,40.37183130860711],
[49.85395342111587,40.37197843751787],
[49.85372811555862,40.372366692823306],
[49.853298962116234,40.37223182544446]
]
]
}
};
var result = GisTools.calculateGeometryArea(options);
containsGeometries
To check if set of geometries are within given geometry pass options to the containsGeometries
function. Returns true if all of the geometries to be checked
are within the given geometry, otherwise returns false.
Options
-
geometry- The geometry, which should contain given set of geometries within its boundaries.Geometry structure
-
type- Type of the geometry. -
coordinates- Coordinates of the geometry.
-
-
geometriesToCheck and geometry- can be any feature type(Polygon,LineString,Point vs). -
geometriesToCheck- Set of geometries to be checked.Geometry structure
-
type- Type of the geometry. -
coordinates- Coordinates of the geometry.
-
Example
Polygon
var options = {
geometry: {
type: 'Polygon',
coordinates: [
[
[51.88568115234373,41.24967690196149],
[50.99029541015624,40.955789183153854],
[51.86920166015624,40.560503838631746],
[51.88568115234373,41.24967690196149]
]
]
},
geometriesToCheck: [
{
type: 'Polygon',
coordinates: [
[
[50.501403808593736,41.013842955224675],
[52.132873535156236,40.292882306191984],
[52.116394042968736,41.377581427340715],
[50.501403808593736,41.013842955224675]
]
]
}
]
};
LineString
var options = {
geometry: {
type: 'Polygon',
coordinates: [
[
[51.88568115234373,41.24967690196149],
[50.99029541015624,40.955789183153854],
[51.86920166015624,40.560503838631746],
[51.88568115234373,41.24967690196149]
]
]
},
geometriesToCheck: [
{
type: 'LineString',
coordinates: [
[52.132873535156236,40.292882306191984],
[52.116394042968736,41.377581427340715]
]
}
]
};
Point
var options = {
geometry: {
type: 'Polygon',
coordinates: [
[
[51.88568115234373,41.24967690196149],
[50.99029541015624,40.955789183153854],
[51.86920166015624,40.560503838631746],
[51.88568115234373,41.24967690196149]
]
]
},
geometriesToCheck: [
{
type: 'Point',
coordinates:
[52.132873535156236,40.292882306191984]
}
]
};
var result = GisTools.containsGeometries(options);
getUnsavedDrawnFeatures
To get unsaved drawn features use getUnsavedDrawnFeatures
function.
Example
var result = GisTools.getUnsavedDrawnFeatures();
initializeMap
To initialize map pass options to the initializeMap function.
Options
-
targetElement- The container for the map, the id of the element. -
tileSettings- Settings of the tile layerSettings structure
-
source- Type of the source. Supported sourcesxyz | tiledWms. -
url- Url of the source. -
serverType- Type of the tile server. This option is only used when source type istiledWms. -
layers- Name of the layer set on the tile server. This option is only used when source type istiledWms. -
extent- An array of numbers representing an extent. This option is only used when source type istiledWms.
-
-
zoomLevel- Optional parameter. Sets the zoom level of the map. If not set then default values will be used. Default value is8 -
center- Optional parameter. Sets the center of the map. If not set then default values will be used.Center structure
-
lat- Optional parameter. Sets the lattitude of the map. If not set then default value will be used. Default value is40.378165 -
lon- Optional parameter. Sets the longitude of the map. If not set then default value will be used. Default value is49.82999
-
Example
var options = {
tileSettings: {
source: 'xyz',
url: 'https://gomap.az/smoothtiles/maptile.do?lng=az&x={x}&y={y}&z={z}&f=png&dp=0'
},
zoomLevel: 12,
center: {
lat: 40.4,
lon: 49.8
},
targetElement: 'map' // Id of the <div> element. Container of the map.
};
GisTools.initializeMap({options: options});
intersectsGeometries
To check if given geometry intesects with a set of geometries pass options to the intersectsGeometries
function. Returns true if given geometry intersects at least
one of the geometry of a geometries set, otherwise returns false.
Options
-
geometry- The geometry, which should contain given set of geometries within its boundaries.Geometry structure
-
type- Type of the geometry. -
coordinates- Coordinates of the geometry.
-
-
geometriesToCheck and geometry- can be any feature type(Polygon,LineString,Point vs). -
geometriesToCheck- Set of geometries to be checked.Geometry structure
-
type- Type of the geometry. -
coordinates- Coordinates of the geometry.
-
Example
Polygon
var options = {
geometry: {
type: 'Polygon',
coordinates: [
[
[51.88568115234373,41.24967690196149],
[50.99029541015624,40.955789183153854],
[51.86920166015624,40.560503838631746],
[51.88568115234373,41.24967690196149]
]
]
},
geometriesToCheck: [
{
type: 'Polygon',
coordinates: [
[
[50.501403808593736,41.013842955224675],
[52.132873535156236,40.292882306191984],
[52.116394042968736,41.377581427340715],
[50.501403808593736,41.013842955224675]
]
]
}
]
};
LineString
var options = {
geometry: {
type: 'Polygon',
coordinates: [
[
[51.88568115234373,41.24967690196149],
[50.99029541015624,40.955789183153854],
[51.86920166015624,40.560503838631746],
[51.88568115234373,41.24967690196149]
]
]
},
geometriesToCheck: [
{
type: 'LineString',
coordinates: [
[52.132873535156236,40.292882306191984],
[52.116394042968736,41.377581427340715]
]
}
]
};
Point
var options = {
geometry: {
type: 'Polygon',
coordinates: [
[
[51.88568115234373,41.24967690196149],
[50.99029541015624,40.955789183153854],
[51.86920166015624,40.560503838631746],
[51.88568115234373,41.24967690196149]
]
]
},
geometriesToCheck: [
{
type: 'Point',
coordinates:
[52.116394042968736,41.377581427340715]
}
]
};
var result = GisTools.intersectsGeometries(options);
modifyFeatureById
To select feature to be modifed, pass options to the modifyFeatureById function.
Options
-
featureId- Id of the feature to be modified.
Example
var options = {
featureId: '00000000-0000-0000-0000-000000000001'
};
GisTools.modifyFeatureById(options);
redoOperation
To redo operation of modify interaction, call redoOperation function.
Example
GisTools.redoOperation();
removeMapInteraction
To remove interaction from the map pass options to the removeMapInteraction function.
Options
-
type- Type of the interaction. Supported interaction typesmodify | translate. -
mode- Mode of the operation. Supported modesrevertBack. When the mode isrevertBackthen it will revert back currently made changes.
Example
var options = {
type: 'modify',
mode: 'revertBack'
};
GisTools.removeMapInteraction({options: options});
removeSplitter
To remove split line to the map use removeSplitter function.
Example
GisTools.removeSplitter();
selectFeatureById
To select the feature pass options to the selectFeatureById function.
Options
-
featureId- Id of the feature to be selected.
Example
var options = {
featureId: '00000000-0000-0000-0000-000000000001'
};
GisTools.selectFeatureById(options);
setBaseApiUrl
To set the base url of api server pass options to the setBaseApiUrl function. This function should be called first,
before every API functions.
Options
-
url- Url of the api server.
Example
var options = {
url: 'https://gistools.sinam.net/api'
};
GisTools.setBaseApiUrl(options);
setFeatureStyleText
To set the text to be shown over the feature, pass options to
the setFeatureStyleText function.
Options
-
featureId- Id of the feature which text will be set. -
text- Text to be shown.
Example
var options = {
featureId: '00000000-0000-0000-0000-000000000001',
text: 'Feature with very long text'
};
GisTools.setFeatureStyleText(options);
setFeatureTooltipText
To set the tooltip text to be shown on hover over the feature, pass options to
the setFeatureTooltipText function.
Options
-
featureId- Id of the feature which tooltip text will be set. -
text- Tooltip text to be shown on hover.
Example
var options = {
featureId: '00000000-0000-0000-0000-000000000001',
text: 'Tooltip text'
};
GisTools.setFeatureTooltipText(options);
undoOperation
To undo operation of draw | modify interactions, call undoOperation function.
Example
GisTools.undoOperation();
zoomToLatLon
To set the center of the map pass options to the zoomToLatLon function.
Options
-
lat- Lattitude of the center. -
lon- Longitude of the center. -
animate- Optional parameter. Available valuestrue | false. Uses the animation while centering map. When set totruethe the animation will be used while centering map. Default value isfalse.
Example
var options = {
lat: 40.4,
lon: 49.8
animate: true
};
GisTools.zoomToLatLon({options: options});
zoomToVectorLayerExtent
Zooms map to extent to fit all features within.
Example
GisTools.zoomToVectorLayerExtent();
Data related functions
This functions are used to manage data.
addFeatures
To save drawn features pass options and callback function to the addFeatures
function. Its only possible to save features, which area is greater than 0 ha. Features with 0
ha area will be ignored.
Options
-
userId- Id of the user which features will be related. -
parentFeatureId- Optional parameter. Id of the parent feature. -
featureTypeId- Id of the Feature type. -
geometry- Geometries of the features to be saved.
Callback Function
-
callback- Function to be called back. Response will be passed to this function. It should be handled inside this function.Response structure
-
success-true | false. If value istruethen features were succesfully saved and function will returnfeature idof saved features. You can checkvalueproperty to get thefeature idof saved features. Iffalsethen it means saving failed. You can checkmessageproperty for the reason of fail. -
message- Additional message about the result of the call. -
value- It will contain thefeature idof saved features if call succeeds. If call fails this property will benull.
-
Example #1
var geometry = GisTools.getUnsavedDrawnFeatures();
var options = {
userId: '00000000-0000-0000-0000-000000000001',
parentFeatureId: '00000000-0000-0000-0000-000000000001',
featureTypeId: '00000000-0000-0000-0000-000000000001',
geometry: geometry
};
function callback(response) {
// Body of the callback function ...
}
GisTools.addFeatures(options, callback);
Example #2
var geometry = [
{
type: 'Polygon',
coordinates: [
[
[51.962585449218736,41.29509110419468],
[51.59454345703123,40.8145887446444],
[52.26470947265622,40.87276658680699],
[51.962585449218736,41.29509110419468]
]
]
}
];
var options = {
userId: '00000000-0000-0000-0000-000000000001',
parentFeatureId: '00000000-0000-0000-0000-000000000001',
featureTypeId: '00000000-0000-0000-0000-000000000001',
geometry: geometry
};
function callback(response) {
// Body of the callback function ...
}
GisTools.addFeatures(options, callback);
cloneFeature
To save cloned feature pass options and callback function to the cloneFeature function.
Options
-
featureId- Id of the feature to be cloned. -
parentFeatureId- Optional parameter. Id of the parent feature.If parentFeatureId is null then parentFeatureId of cloned feature will also be null. -
featureTypeId- Optional parameter. Id of the Feature type.If featureTypeId is null then featureTypeId will not change.
Callback Function
-
callback- Function to be called back. Response will be passed to this function. It should be handled inside this function.Response structure
-
success-true | false. If value istruethen feature was successfully cloned. Clone will be created over original feature. You can checkvalueproperty to get thefeature id. Iffalsethen it means saving failed. You can checkmessageproperty for the reason of fail. -
message- Additional message about the result of the call. -
value- It will contain thefeature idif call succeeds. If call fails this property will benull.
-
Example
var options = {
parentFeatureId: '00000000-0000-0000-0000-000000000001',
featureTypeId: '00000000-0000-0000-0000-000000000001'
};
function callback(response) {
// Body of the callback function ...
}
GisTools.cloneFeature(options, callback);
featureIntersectsWithLayer
To check if feature intersects with layer, pass options and
callback function to the featureIntersectsWithLayer function.
Options
-
featureId- Id of the feature to check. -
featureTypeId- Id of the layer to check against.
Callback Function
-
callback- Function to be called back. Response will be passed to this function. It should be handled inside this function.Response structure
-
success-true | false. If value istruethen the check was succesfully done. You can checkvalueproperty to get the result of intersection operation. Iffalsethen it means check failed. You can checkmessageproperty for the reason of fail. -
message- Additional message about the result of the call. -
value- It will contain theintersectproperty, which will indicate the result of check, if call succeeds. If call fails this property will benull.
-
Example
var options = {
featureId: '00000000-0000-0000-0000-000000000001',
featureTypeId: '00000000-0000-0000-0000-000000000001'
};
function callback(response) {
// Body of the callback function ...
}
GisTools.featureIntersectsWithLayer(options, callback);
featureTypes
To get feature types pass callback function to the featureTypes function. Returns feature types.
Callback Function
-
callback- Function to be called back. Response will be passed to this function. It should be handled inside this function.Response structure
-
success-true | false. If value istruethen feature types are returned. Iffalsethen it means getting feature types failed. You can checkmessageproperty for the reason of fail. -
message- Additional message about the result of the call. -
value- It will containfeature typesif call succeeds. This value will be returned as JSON object. If call fails this property will benull.
-
Example
function callback(response) {
// Body of the callback function ...
}
GisTools.featureTypes(callback);
getFeatureGeometryById
To get the geometry of the feature pass options and callback function to the getFeatureGeometryById
function. You can pass multiple ids at the same time, this function receives ids as array.
Options
-
featureIdList- Ids of the features which geometries will be retrieved. -
source- Optional parameter. Indicates the source of the feature. Supported sources aremap | server. Usemapto get the geometry of the feature which is currently available on the map. Useserverto get it from server. You can omit this parameter. Default value isserver.
Callback Function
-
callback- Function to be called back. Response will be passed to this function. It should be handled inside this function.Response structure
-
success-true | false. If value istruethen it means geometries successfully retrieved. You can checkvalueproperty to get thegeometries. Iffalsethen it means retieving failed. You can checkmessageproperty for the reason of fail. -
message- Additional message about the result of the call. -
value- It will contain thegeometriesif call succeeds. If call fails this property will benull.
-
Example #1
var options = {
featureIdList: ['00000000-0000-0000-0000-000000000001', '00000000-0000-0000-0000-000000000002']
};
function callback(response) {
// Body of the callback function ...
}
GisTools.getFeatureGeometryById(options, callback);
Example #2
var options = {
source: 'map',
featureIdList: ['00000000-0000-0000-0000-000000000001', '00000000-0000-0000-0000-000000000002']
};
function callback(response) {
// Body of the callback function ...
}
GisTools.getFeatureGeometryById(options, callback);
loadFeatures
To load the features pass options to the loadFeatures function.
Options
-
userId- Id of the user which features will be loaded.t -
featureIdList- Ids of the features which will be loaded.It will also load features whichparentFeatureIdare equal to the one of the ids provided in this list.
Example
var options = {
userId: '00000000-0000-0000-0000-000000000001',
featureIdList: ['00000000-0000-0000-0000-000000000001', '00000000-0000-0000-0000-000000000002']
};
GisTools.loadFeatures({options: options});
mergeFeatures
To save merged features pass callback function to the mergeFeatures function.
Callback Function
-
callback- Function to be called back. Response will be passed to this function. It should be handled inside this function.Response structure
-
success-true | false. If value istruethen features were successfully merged. You can checkvalueproperty to get thefeature id. Iffalsethen it means merging failed. You can checkmessageproperty for the reason of fail. -
message- Additional message about the result of the call. -
value- It will contain thefeature idif call succeeds. If call fails this property will benull.
-
Example
function callback(response) {
// Body of the callback function ...
}
GisTools.mergeFeature(callback);
modifyFeature
To modify feature pass options and callback
function to the modifyFeature function.
Options
-
mode- Indicates how function will behave. Supported modes areinteraction | manual. Useinteractionmode to save feature which is currently manipulated bymodifyinteraction. Or usemanualmode to manually set parameters of feature which should be modified. -
featureId- Id of the feature to be modified. This parameter is only used onmanualmode. -
geometry- Geometry of the feature to be modified. This parameter is only used onmanualmode.
Example #1
var options = {
mode: 'interaction'
};
function callback(response) {
// Body of the callback function ...
}
GisTools.modifyFeature(options, callback);
Example #2
var options = {
mode: 'manual',
featureId: '00000000-0000-0000-0000-000000000001',
geometry: {
type: 'Polygon',
coordinates: [
[
[49.853298962116234, 40.37223182544446],
[49.8535457253456, 40.37183130860711],
[49.8535457253456, 40.37183130860711],
[49.85395342111587, 40.37197843751787],
[49.85372811555862, 40.372366692823306],
[49.853298962116234, 40.37223182544446]
]
]
}
};
function callback(response) {
// Body of the callback function ...
}
GisTools.modifyFeature(options, callback);
registerUser
To register user pass options and callback function to the registerUser
function.
Options
-
userId- Id of the user to be registered
Callback Function
-
callback- Function to be called back. Response will be passed to this function. It should be handled inside this function.Response structure
-
success-true | false. If value istruethen it means registration succeed and function will returnuser id. You can checkvalueproperty to get theuser id. Iffalsethen it means registration failed. You can checkmessageproperty for the reason of fail. -
message- Additional message about the result of the call. -
value- It will contain theuser idif call succeeds. If call fails this property will benull.
-
Example
var options = {
userId: '00000000-0000-0000-0000-000000000001'
};
function callback(response) {
// Body of the callback function ...
}
GisTools.registerUser(options, callback);
removeFeature
To remove feature pass callback function to the removeFeature
function.
Callback Function
-
callback- Function to be called back. Response will be passed to this function. It should be handled inside this function.Response structure
-
success-true | false. If value istruethen feature was successfully removed. Iffalsethen it means saving failed. You can checkmessageproperty for the reason of fail. -
message- Additional message about the result of the call.
-
Example
function callback(response) {
// Body of the callback function ...
}
GisTools.removeFeature(callback);
splitFeature
To save splitted feature pass callback function to the splitFeature function.
Callback Function
-
callback- Function to be called back. Response will be passed to this function. It should be handled inside this function.Response structure
-
success-true | false. If value istruethen feature was successfully splitted. You can checkvalueproperty to get thelist of feature ids. Iffalsethen it means saving failed. You can checkmessageproperty for the reason of fail. -
message- Additional message about the result of the call. -
value- It will contain thelist of feature idsif call succeeds. If call fails this property will benull.
-
Example
function callback(response) {
// Body of the callback function ...
}
GisTools.splitFeature(callback);
tiles
To get the list of tiles pass callback function to the tiles
function.
Callback Function
-
callback- Function to be called back. Response will be passed to this function. It should be handled inside this function.Response structure
-
success-true | false. If value istruethen you can retrieve tiles fromvalue. Iffalsethen it means retrieving tiles failed. You can checkmessageproperty for the reason of fail. -
message- Additional message about the result of the call.
-
Example
function callback(response) {
// Body of the callback function ...
}
GisTools.tiles(callback);
translateFeature
To save dragged feature pass callback function to the translateFeature function.
Callback Function
-
callback- Function to be called back. Response will be passed to this function. It should be handled inside this function.Response structure
-
success-true | false. If value istruethen drag on feature was succesfully saved. Iffalsethen it means saving failed. You can checkmessageproperty for the reason of fail. -
message- Additional message about the result of the call.
-
Example
function callback(response) {
// Body of the callback function ...
}
GisTools.translateFeature(callback);
Url based
This apis are called by HTTP requests. Structure of the request {hostname}/api/{request}
/feature/intersect/layer
Checks if feature intersects with layer. Example of calling (localhost/api/feature/intersect/layer).
Method type: POST
Request structure
-
featureId- Id of the feature to check. -
featureTypeId- Id of the layer to check against.
Response structure
-
success-true | false. If value istruethen the check was successfully done. You can checkvalueproperty to get the result of intersection operationintersect. Iffalsethen it means check failed. You can checkmessageproperty for the reason of fail. -
message- Additional message about the result of the call. -
value- It will contain theintersectproperty, which will indicate the result of check, if call succeeds. This value will be returned as a JSON object. You can getresult of intersectionfrom this object as aintersect. If call fails this property will benull.
Example
var model = {
featureId: '00000000-0000-0000-0000-000000000001',
featureTypeId: '00000000-0000-0000-0000-000000000001'
};
fetch(`https://gistools.sinam.net/api/feature/intersect/layer`, {
method: 'post',
headers: new Headers({
'Accept': 'application/json',
'Content-Type': 'application/json'
}),
body: JSON.stringify(model)
})
.then(function (response) {
if (response.ok) {
response.json().then(function (response) {
// Response handling code...
})
}
})
/user/count
Returns count of the registered users. Example of calling (localhost/api/user/count).
Method type: GET
Response structure
-
success-true | false. If value istruethen function will returncountof the registered users. You can checkvalueproperty to get thecount. Iffalsethen it means getting count of the users failed. You can checkmessageproperty for the reason of fail. -
message- Additional message about the result of the call. -
value- It will contain thecountof the registered users if call succeeds. This value will be returned as JSON object. You can getcountfrom this object as acount. If call fails this property will benull.
Example
fetch(`https://gistools.sinam.net/api/user/count`, {
method: 'get',
headers: new Headers({
'Accept': 'application/json',
'Content-Type': 'application/json'
})
})
.then(function (response) {
if (response.ok) {
response.json().then(function (response) {
// Response handling code...
})
}
})