编辑WFS后,Openlayers会破坏几何体

时间:2012-07-23 08:20:56

标签: javascript openlayers

我在编辑WFS图层时遇到问题。编辑对象后我保存了一个对象,但出了点问题。保存对象的几何图形被破坏后。尝试在GEoservers图层预览中查看图层并找不到已编辑的对象。

有我的代码。

if(counter==0){
                    if(ppp==null){
                                if (edit==null){
                                    edit = new OpenLayers.Control.ModifyFeature(myVecLayer);
                                    map.addControl(edit);
                                    ppp=map.getControlsByClass("OpenLayers.Control.ModifyFeature");
                                }
                            }

                                map.addLayers([myVecLayer]);
                                Ffilter = new OpenLayers.Filter.Comparison({
                                        type: OpenLayers.Filter.Comparison.EQUAL_TO,
                                        property: 'id',
                                        value: '170',
                                    })
                                myVecLayer.filter=Ffilter;
                                myVecLayer.refresh({force: true});
                            for(var i=0;i<ppp.length;i++){
                                ppp[i].activate();
                            }
                            counter=1;

                }
                else {
                    //FS.deactivate();
                    SS.save();
                    //myVecLayer.destroyFeatures(); 
                    map.removeLayer(myVecLayer); 
                    for(var i=0;i<ppp.length;i++){
                                ppp[i].deactivate();
                            }
                    //ppp.deactivate();
                    counter=0;
                }

和WFS

SS=new OpenLayers.Strategy.Save();
osm = new OpenLayers.Layer.OSM( "OpenStreet Maps");
//WFS
                            var myStyle = OpenLayers.Util.extend({},
                                OpenLayers.Feature.Vector.style['default']);
                            myStyle.strokeWidth = 1.5;
                            myStyle.strokeColor = "#ff0000";
                            myStyle.fillOpacity = 0.1;
                            OpenLayers.ProxyHost = "proxy.cgi?url=";
                            var renderer = OpenLayers.Util.getParameters(window.location.href).renderer;
                            renderer = (renderer) ? [renderer] : OpenLayers.Layer.Vector.prototype.renderers;           
                            myVecLayer = new OpenLayers.Layer.Vector("Редактируемый участок", {
                                strategies: [new OpenLayers.Strategy.BBOX(), SS],
                                style: myStyle,
                                protocol: new OpenLayers.Protocol.WFS({
                                    version: "1.0.0",
                                    srsName:"EPSG:900913",
                                    url: "http://localhost:8080/geoserver/wfs",
                                    featureType: "filedata",
                                    featureNS: "http://www.opengeospatial.net/cite",
                                    defaultFilter : filter
                                }),
                                renderers: renderer
                            })  

1 个答案:

答案 0 :(得分:0)

这是地理服务器上的图层选项的问题。要完成所有工作,需要使用“Keep native SRS”。