Leaflet 反应传单绘制:访问多边形';s保存时的坐标数组

Leaflet 反应传单绘制:访问多边形';s保存时的坐标数组,leaflet,leaflet.draw,react-leaflet,Leaflet,Leaflet.draw,React Leaflet,我有一个组件可以在地图上放置一个可编辑的多边形。当用户点击“保存”按钮时,我想访问多边形新顶点的数组,以便保存它们。我该怎么做 我的组件: <FeatureGroup> <EditControl position="topright" onEdited={e => console.log(e)} edit={{ remove: false }} draw={{ mark

我有一个组件可以在地图上放置一个可编辑的多边形。当用户点击“保存”按钮时,我想访问多边形新顶点的数组,以便保存它们。我该怎么做

我的组件:

<FeatureGroup>
    <EditControl
        position="topright"
        onEdited={e => console.log(e)}
        edit={{ remove: false }}
        draw={{
                marker: false,
                circle: false,
                rectangle: false,
                polygon: false,
                polyline: false
             }}
        />
        <Polygon positions={polygonCoords} />;
</FeatureGroup>

console.log(e)}
编辑={{remove:false}
画={{
马克:错,
圆圈:错,
矩形:假,
多边形:错,
多段线:false
}}
/>
;
我得到的两份推荐信:


我知道我必须实现某种函数来处理OneEded钩子和由此生成的事件,但有人知道我如何从该事件中获取新的顶点数组吗?

对于其他正在努力解决此问题的人,这里有一个ES6的有效解决方案:

        <FeatureGroup>
            <EditControl
                position="topright"

                //this is the necessary function. It goes through each layer
                //and runs my save function on the layer, converted to GeoJSON 
                //which is an organic function of leaflet layers.

                onEdited={e => {
                    e.layers.eachLayer(a => {
                        this.props.updatePlot({
                            id: id,
                            feature: a.toGeoJSON()
                        });
                    });
                }}
                edit={{ remove: false }}
                draw={{
                    marker: false,
                    circle: false,
                    rectangle: false,
                    polygon: false,
                    polyline: false
                }}
            />
            <Polygon positions={[positions(this.props)]} />;
        </FeatureGroup>
    );

{
e、 层。每个层(a=>{
this.props.updatePlot({
id:id,
特性:a.toGeoJSON()
});
});
}}
编辑={{remove:false}
画={{
马克:错,
圆圈:错,
矩形:假,
多边形:错,
多段线:false
}}
/>
;
);