实际上,我正在将此代码用于带有弹出示例的 GetFeatureInfo,现在我想限制弹出窗口中的字段。
<html>
<head>
<title>GetFeatureInfo Popup</title>
<script src="ol/OpenLayers.js"></script>
<link rel="stylesheet" href="ol/theme/default/style.css" type="text/css" />
<link rel="stylesheet" href="ol/examples/style.css" type="text/css" />
<script>
OpenLayers.ProxyHost = "/cgi-bin/proxy.cgi?url=";
/*Same as identifier*/
var map, info;
function load() {
map = new OpenLayers.Map({
div: "map",
maxExtent: new OpenLayers.Bounds(143.834,-43.648,148.479,-39.573)
});
var political = new OpenLayers.Layer.WMS("State Boundaries",
"http://localhost:8080/geoserver/wms",
{'layers': 'topp:tasmania_state_boundaries', transparent: true, format: 'image/gif'},
{isBaseLayer: true}
);
var roads = new OpenLayers.Layer.WMS("Roads",
"http://localhost:8080/geoserver/wms",
{'layers': 'topp:tasmania_roads', transparent: true, format: 'image/gif'},
{isBaseLayer: false}
);
var cities = new OpenLayers.Layer.WMS("Cities",
"http://localhost:8080/geoserver/wms",
{'layers': 'topp:tasmania_cities', transparent: true, format: 'image/gif'},
{isBaseLayer: false}
);
var water = new OpenLayers.Layer.WMS("Bodies of Water",
"http://localhost:8080/geoserver/wms",
{'layers': 'topp:tasmania_water_bodies', transparent: true, format: 'image/gif'},
{isBaseLayer: false}
);
map.addLayers([political, roads, cities, water]);
info = new OpenLayers.Control.WMSGetFeatureInfo({
url: 'http://localhost:8080/geoserver/wms',
title: 'Identify features by clicking',
queryVisible: true,
eventListeners: {
getfeatureinfo: function(event) {
map.addPopup(new OpenLayers.Popup.FramedCloud(
"chicken",
//document.getElementById('get').innerHTML = xmlResponse.attribute.state;
map.getLonLatFromPixel(event.xy),
null,
event.text,
null,
true
));
xmlResponse = new OpenLayers.Format.XML().read(event.text);
document.getElementById('h').innerHTML = xmlResponse.attribute.STATE;
}
}
});
map.addControl(info);
info.activate();
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.zoomToMaxExtent();
}
</script>
</head>
<body onload="load()">
<h1 id="title">Feature Info in Popup</h1>
<div id="tags"></div>
<p id="shortdesc">
Demonstrates the WMSGetFeatureInfo control for fetching information
about a position from WMS (via GetFeatureInfo request). Results
are displayed in a popup.
</p>
<div id="map" class="smallmap"></div>
<form>
<input type="lable" id="h">
</form>
<div id="docs"></div>
</body>
</html>
现在我只想要特定字段或限制弹出功能中的字段。请指导我,我是新手。