Clone Feature

To clone feature first select feature on map then click Clone button from the toolbar.

To save cloned feature pass callback function to the cloneFeature 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 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
// 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 guideCloneButton = document.getElementsByClassName('guide-clone-button');

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

    GisTools.cloneFeature(callBack);

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