我正在尝试在 OpenLayers 地图上显示 WFS 图层。以下是GETCAPABILITIES响应的适当部分。
<ows:Operation name="GetFeature">
<ows:DCP>
<ows:HTTP>
<ows:Get xlink:href="http://localhost/MapServer/Default.aspx"/>
<ows:Post xlink:href="http://localhost/MapServer/Default.aspx"/>
</ows:HTTP>
</ows:DCP>
<ows:Parameter name="resultType">
<ows:Value>results</ows:Value>
<ows:Value>hits</ows:Value>
</ows:Parameter>
<ows:Parameter name="outputFormat">
<ows:Value>text/xml; subtype=gml/3.1.1</ows:Value>
</ows:Parameter>
</ows:Operation>
<ows:Parameter name="srsName">
<ows:Value>EPSG:4326</ows:Value>
</ows:Parameter>
<ows:Constraint name="DefaultMaxFeatures">
<ows:Value>20000</ows:Value>
</ows:Constraint>
我要显示的功能:
<wfs:FeatureType>
<wfs:Name>Data_ACTIVE</wfs:Name>
<wfs:Title/>
<wfs:Abstract/>
<ows:Keywords/>
<wfs:DefaultSRS>EPSG:4326</wfs:DefaultSRS>
<wfs:OutputFormats>
<wfs:Format>text/xml; subtype=gml/3.1.1</wfs:Format>
</wfs:OutputFormats>
<ows:WGS84BoundingBox>
<ows:LowerCorner>-102.01545715332 28.970645904541</ows:LowerCorner>
<ows:UpperCorner>-71.021598815918 43.1671752929688</ows:UpperCorner>
</ows:WGS84BoundingBox>
</wfs:FeatureType>
这是我正在使用的代码:
$(document).ready(
function () {
// allow testing of specific renderers via "?renderer=Canvas", etc
var renderer = OpenLayers.Util.getParameters(window.location.href).renderer;
renderer = (renderer) ? [renderer] : OpenLayers.Layer.Vector.prototype.renderers;
var geographic = new OpenLayers.Projection("EPSG:4326");
var mercator = new OpenLayers.Projection("EPSG:900913");
map = new OpenLayers.Map({
div: "map",
layers: [
new OpenLayers.Layer.WMS("OpenLayers WMS",
"http://vmap0.tiles.osgeo.org/wms/vmap0",
{ layers: "basic" }
),
new OpenLayers.Layer.Vector("GML", {
strategies: [new OpenLayers.Strategy.Fixed()],
protocol: new OpenLayers.Protocol.WFS({
url: "http://localhost/MapServer/Default.aspx",
featureType: "Data_ACTIVE",
featureNS: "http://www.tstgis.org/gml",
version: "1.1.0",
geometryName: "line"
}),
renderers: renderer
})
],
zoom: 15
});
var bb = new OpenLayers.Bounds(-179.821327209473, 12.1057098342161, -56.5289154052734, 78.1442901657839);
map.zoomToExtent(bb);
});
我看到正在向服务器发出该图层的发布请求,结果返回,但根本不显示。为什么图层不显示?任何帮助,将不胜感激。
注意
此测试脚本是在 localhost/mapserver 下运行的 HTML shell 的一部分,因此它排除了熟悉的跨域问题。