Split Feature

To split feature first select feature on map then click Split button from the toolbar. Draw intersection line to split the geometry then click on Save button to save splitted feature.

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
// Initialization of the map
var options = {
    tileSettings: {
        source: 'xyz',
        url: 'https://gomap.az/smoothtiles/maptile.do?lng=az&x={x}&y={y}&z={z}&f=png&dp=0'
    },
    targetElement: 'map' // Id of the <div> element. Container of the map.
};

GisTools.initializeMap({options: options});

var options = {
    userId: '00000000-0000-0000-0000-000000000001',
    featureIdList: ['00000000-0000-0000-0000-000000000001', '00000000-0000-0000-0000-000000000002']
};
GisTools.loadFeatures({options: options});

// Adding select interaction
var interactionOptions = {
    type: 'select'
};
GisTools.addMapInteraction({options: interactionOptions});

var guideSplitButton = document.getElementsByClassName('guide-split-button');

guideSplitButton[0].addEventListener('click', function () {
    GisTools.addSplitter();
});

var guideSplitCancelButton = document.getElementsByClassName('guide-split-cancel-button');

guideSplitCancelButton[0].addEventListener('click', function () {
    GisTools.removeSplitter();
});

var guideSplitSaveButton = document.getElementsByClassName('guide-split-save-button');

guideSplitSaveButton[0].addEventListener('click', function () {

    GisTools.splitFeature(callBack);

    function callBack(response) {
        if (response.success === true) { // Success
            console.log(response);
            alert(response.message);
        } else if (response.success === false) { // Fail
            console.log(response);
        }
    }
});