Code Monkey home page Code Monkey logo

Comments (6)

GastonZalba avatar GastonZalba commented on July 28, 2024

Hello, thanks for the notice. I will check this

from ol-wfst.

GastonZalba avatar GastonZalba commented on July 28, 2024

I'm improving this method and will upload a new version today, but i can't find where could be the error. I cannot find a 'forEach' anywhere close the line 1456 in any version (dist, lib, src). If you can, send me all the code you have, or at least the wfst initialization and a image of the code line throwing the error.

And why are you editing the ol-wfst.js directly? Can't you add that extra code without changing the library?

from ol-wfst.

adam-sal avatar adam-sal commented on July 28, 2024

Thanks for your response.

In the meantime, there have been changes to my code. Currently i add extra code without changing the library. The new part of the code after wfst initialization:

                map.addControl(wfst);
                const copyButton = document.createElement('button');
                copyButton.className = 'ol-wfst--tools-control-btn ol-wfst--tools-control-btn-copy';
                copyButton.type = 'button';
                copyButton.innerHTML = `<img src="./ol-wfst-main/ol-wfst-main/src/assets/images/copy-svgrepo-com.svg"/>`;
                copyButton.title = 'Skopiuj geometrię działki';
                copyButton.disabled = "disabled";
                copyButton.onclick = () => {
                    wfst._transactWFS('insert', [feature_to_copy], wfst._layerToInsertElements);
                    copyButton.disabled = "disabled";
                    feature_to_copy = null;
                    map.getLayers().forEach(function (layer) {
                        console.log(layer.get('title'));
                        if (layer.get('title') != undefined && layer.get('title').includes('Warstwa terenowcy')) {
                            setTimeout(function(){ layer.getSource().refresh(); }, 500);
                            }
                        });
                };

When i click the button i receive this error:
ol-wfst.ts:1702 Cannot read properties of undefined (reading 'forEach')
* @param feature * @private */ _deselectEditFeature(feature: FeatureLike): void { this._removeOverlayHelper(feature); }

feature_to_copy is the ol.Feature created basis on WKT Polygon with no properties

Despite the error, the WFS transaction executes and the feature is added to WFS-T.

I made some changes in library to avoid showing up the modal with this error, but maybe you will recognize the source of the problem.

from ol-wfst.

GastonZalba avatar GastonZalba commented on July 28, 2024

Send me the new Wfst({...}) section of your code

from ol-wfst.

adam-sal avatar adam-sal commented on July 28, 2024
const wfst = new Wfst({
geoServerUrl: 'http://10.0.10.10:8080/geoserver/openlayers/wms',
geoServerAdvanced: {
    getCapabilitiesVersion: '1.3.0',
    getFeatureVersion: '1.0.0',
    describeFeatureTypeVersion: '1.1.0',
    lockFeatureVersion: '1.1.0',
    projection: 'EPSG:3857',
},
layers: [
    {
        name: 'warstwaTerenowcy', // Name of the layer on the GeoServer
        label: 'Warstwa terenowcy', // Optional Label to be displayed in the controller
        mode: 'wfs',
        wfsStrategy: 'all',
        zIndex: 99,
        style: style_warstwa_terenowcy_0,
        namespace: "openlayers",
    }
],
language: 'en',
minZoom: 1,
showUpload: true,
showControl: true,
uploadFormats: '.kml',
beforeInsertFeature: function (feature) {
    return feature;
}
});

from ol-wfst.

GastonZalba avatar GastonZalba commented on July 28, 2024

The code should be wfst.insertFeaturesTo('warstwaTerenowcy', [feature_to_copy]);. Try that, but still i have no idea which forEach is throwing the error (lines 1456 and 1702 do not have it).

Keep in mind that if you call private attributes and methods outside the library, these could break in next updates...

from ol-wfst.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.