你可以帮我在GEOExt上使用WFS吗?我读了教程并看到了这段代码。
proxy: new GeoExt.data.ProtocolProxy({
protocol: new OpenLayers.Protocol.WFS({
url: "/geoserver/ows",
version: "1.1.0",
featureType: "parks",
featureNS: "http://medford.opengeo.org",
srsName: "EPSG:4326"
})
})
在此之后我看到这个var vectorLayer = new OpenLayers.Layer.Vector(“Editable features”);并且不了解如何创建图层。所以我有一些问题
1如何获取wfs的URL? (我使用geoserver)
2什么意思是featureType选项
3更重要的是。这段代码是对的吗?我在这里找到http://workshops.opengeo.org/geoext/wfs/grid.html
答案 0 :(得分:0)
希望它可以帮助某人
//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(), new OpenLayers.Strategy.Save()],
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"
}),
renderers: renderer
})
app.mapPanel.map.addLayers([myVecLayer]);
featureType
geoserver中图层的名称
wokspace的featureType
路径(也可以在geoserver中看到)