1

<script
src="http://www.openstreetmap.org/openlayers/OpenStreetMap.js">
</script>
<script type="text/javascript">
function init() {
 var map = new OpenLayers.Map ("map", {
controls:[
new OpenLayers.Control.Navigation(),
new OpenLayers.Control.PanZoom()
]
} );

var openstreetmap = new OpenLayers.Layer.OSM();
var style = new OpenLayers.Style();
var rule= new OpenLayers.Rule({
filter: new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.EQUAL_TO,
property: "district",
value: "1",
}),
symbolizer: {
fillColor: "#FF7144",
fillOpacity: 0.6,
strokeColor: "#FF0000",
strokeWidth: 2,
strokeDashstyle: "solid",
label: " ${district}",
labelAlign: "cc",
fontColor: "#000000",
fontOpacity: 1,
fontFamily: "Arial",
fontSize: 16,
fontWeight: "600"}
});
style.addRules([rule]);

var wfs_layer = new OpenLayers.Layer.Vector("fsa", {
strategies: [new OpenLayers.Strategy.BBOX()],
styleMap: style,
protocol: new OpenLayers.Protocol.WFS({
version: "1.1.0",
url: "http://localhost:8080/geoserver/wfs",
featurePrefix: "india",
featureNS :  "http://opengeo.org/india",
featureType: "india",
})
});
map.addLayers([openstreetmap,wfs_layer]);
var WGS84 = new OpenLayers.Projection("EPSG:4326");
var mapextent = new OpenLayers.Bounds(-123.294, 49.296, -122.953, 49.411).transform(WGS84,       map.getProjectionObject());
map.zoomToExtent(mapextent);
}
</script>

此代码在 geoserver 中运行良好,但是当我在 wampserver(PHP) 中尝试此代码时,仅显示 WMS 层。我已经阅读了许多与在 OpenLayers 中添加 WFS 层相关的教程和堆栈溢出查询,但在我的情况下没有任何工作......我还尝试了 proxy.cgi 脚本以允许代理调用地理服务器,但它不起作用。CGI 代理脚本只能与 Python 一起使用还是也可以与 PHP 一起使用?

4

0 回答 0