API

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 are select | draw | modify | translate | snap | modifyAndTranslate. Snap interaction automatically added on draw | modify | split | modifyAndTranslate operations. modifyAndTranslate interaction is a combination of modify and translate interactions. When modify | modifyAndTranslate interactions are added you can remove vertex. To remove vertex, select it by clicking on it then click Right mouse button on it.
  • geometryType - Type of the geometry. Supported geometry types are Point | Polygon This parameter is required only for draw interaction. 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 for select | draw interaction. 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 layer
    Settings structure
    • source - Type of the source. Supported sources xyz | tiledWms.
    • url - Url of the source.
    • serverType - Type of the tile server. This option is only used when source type is tiledWms.
    • layers - Name of the layer set on the tile server. This option is only used when source type is tiledWms.
    • extent - An array of numbers representing an extent. This option is only used when source type is tiledWms.
  • zoomLevel - Optional parameter. Sets the zoom level of the map. If not set then default values will be used. Default value is 8
  • 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 is 40.378165
    • lon - Optional parameter. Sets the longitude of the map. If not set then default value will be used. Default value is 49.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 types modify | translate.
  • mode - Mode of the operation. Supported modes revertBack. When the mode is revertBack then 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 values true | false. Uses the animation while centering map. When set to true the the animation will be used while centering map. Default value is false.
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();

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 is true then features were succesfully saved and function will return feature id of saved features. You can check value property to get the feature id of saved features. If false then it means saving failed. You can check message property for the reason of fail.
    • message - Additional message about the result of the call.
    • value - It will contain the feature id of saved features if call succeeds. If call fails this property will be null.
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 is true then feature was successfully cloned. Clone will be created over original feature. You can check value property to get the feature id. If false then it means saving failed. You can check message property for the reason of fail.
    • message - Additional message about the result of the call.
    • value - It will contain the feature id if call succeeds. If call fails this property will be null.
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 is true then the check was succesfully done. You can check value property to get the result of intersection operation. If false then it means check failed. You can check message property for the reason of fail.
    • message - Additional message about the result of the call.
    • value - It will contain the intersect property, which will indicate the result of check, if call succeeds. If call fails this property will be null.
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 is true then feature types are returned. If false then it means getting feature types failed. You can check message property for the reason of fail.
    • message - Additional message about the result of the call.
    • value - It will contain feature types if call succeeds. This value will be returned as JSON object. If call fails this property will be null.
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 are map | server. Use map to get the geometry of the feature which is currently available on the map. Use server to get it from server. You can omit this parameter. Default value is server.
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 is true then it means geometries successfully retrieved. You can check value property to get the geometries. If false then it means retieving failed. You can check message property for the reason of fail.
    • message - Additional message about the result of the call.
    • value - It will contain the geometries if call succeeds. If call fails this property will be null.
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 which parentFeatureId are 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 is true then features were successfully merged. You can check value property to get the feature id. If false then it means merging failed. You can check message property for the reason of fail.
    • message - Additional message about the result of the call.
    • value - It will contain the feature id if call succeeds. If call fails this property will be null.
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 are interaction | manual. Use interaction mode to save feature which is currently manipulated by modify interaction. Or use manual mode to manually set parameters of feature which should be modified.
  • featureId - Id of the feature to be modified. This parameter is only used on manual mode.
  • geometry - Geometry of the feature to be modified. This parameter is only used on manual mode.
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 is true then it means registration succeed and function will return user id. You can check value property to get the user id. If false then it means registration failed. You can check message property for the reason of fail.
    • message - Additional message about the result of the call.
    • value - It will contain the user id if call succeeds. If call fails this property will be null.
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 is true then feature was successfully removed. If false then it means saving failed. You can check message property 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 is true then feature was successfully splitted. You can check value property to get the list of feature ids. If false then it means saving failed. You can check message property for the reason of fail.
    • message - Additional message about the result of the call.
    • value - It will contain the list of feature ids if call succeeds. If call fails this property will be null.
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 is true then you can retrieve tiles from value. If false then it means retrieving tiles failed. You can check message property 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 is true then drag on feature was succesfully saved. If false then it means saving failed. You can check message property 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 is true then the check was successfully done. You can check value property to get the result of intersection operation intersect. If false then it means check failed. You can check message property for the reason of fail.
  • message - Additional message about the result of the call.
  • value - It will contain the intersect property, which will indicate the result of check, if call succeeds. This value will be returned as a JSON object. You can get result of intersection from this object as a intersect. If call fails this property will be null.
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 is true then function will return count of the registered users. You can check value property to get the count. If false then it means getting count of the users failed. You can check message property for the reason of fail.
  • message - Additional message about the result of the call.
  • value - It will contain the count of the registered users if call succeeds. This value will be returned as JSON object. You can get count from this object as a count. If call fails this property will be null.
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... 
        })
    }
})