Страница 1 из 1

Map Server+OpenLayers.Protocol.WFS

Добавлено: 07 окт 2015, 09:11
yura3452
Хочу сделать ,чтобы работало выделение слоев в OL. По-видимому не работает запрос OpenLayers.Protocol.WFS.fromWMSLayer
полный js:

Код: Выделить всё

var map, infoControls, green, select, hover, control1;

		function load() {
			map = new OpenLayers.Map('map', {
				maxExtent: new OpenLayers.Bounds(12638228, 6656449, 12667930, 6676928),
				projection: "EPSG:28412",
				units: "m"
			});

			green = new OpenLayers.Layer.WMS("Геоботаника",
				"http://localhost/cgi-bin/mapserv.exe?map=/ms4w/apps/example/geobotanic.map&", 
				{'layers': 'green', transparent: false, format: 'PNG'},
				{isBaseLayer: true}
				);

			var gidro = new OpenLayers.Layer.WMS("Основная гидрография",
				"http://localhost/cgi-bin/mapserv.exe?map=/ms4w/apps/example/geobotanic.map&", 
				{'layers': 'gidro', transparent: true, format: 'PNG'},
				{isBaseLayer: false}
				);

			var river = new OpenLayers.Layer.WMS("Мелкие реки",
				"http://localhost/cgi-bin/mapserv.exe?map=/ms4w/apps/example/geobotanic.map&", 
				{'layers': 'river', transparent: true, format: 'PNG'},
				{isBaseLayer: false}
				);

			var styleMap = new OpenLayers.StyleMap({
				'strokeWidth': 5,
				'strokeColor': '#ff0000'
			});

			select = new OpenLayers.Layer.Vector("Selection", {
				styleMap: new OpenLayers.Style(OpenLayers.Feature.Vector.style["select"])
			});
			hover = new OpenLayers.Layer.Vector("Hover");

			control1 = new OpenLayers.Control.GetFeature({
				protocol: OpenLayers.Protocol.WFS.fromWMSLayer(green, {
					featureType: "green",
					version: "1.0.0",
					url:  "http://localhost/cgi-bin/mapserv.exe?map=/ms4w/apps/example/geobotanic.map&SERVICE=WFS&srsName=EPSG:28412",
					srsName:"EPSG:28412",
					geometryName: "mygeom"
				}),
				box: false,
				hover: true
			});


			control1.events.register("featureselected", this, function(e) {
				select.addFeatures([e.feature]);
			});
			control1.events.register("featureunselected", this, function(e)
			{
				select.removeFeatures([e.feature]);
			});
			control1.events.register("hoverfeature", this, function(e) {
				hover.addFeatures([e.feature]);
			});
			control1.events.register("outfeature", this, function(e) {
				hover.removeFeatures([e.feature]);
			});
			map.addControl(control1);
			control1.activate();

			infoControls = {
				click: new OpenLayers.Control.WMSGetFeatureInfo({
					url: 'http://localhost/cgi-bin/mapserv.exe?map=/ms4w/apps/example/geobotanic.map&', 
					title: 'Identify features by clicking',
					layers: [green],
					queryVisible: true,
					infoFormat: 'text/html'
				})
			};

			map.addLayers([river,green,gidro,select,hover]); 
			for (var i in infoControls) { 
				infoControls[i].events.register("getfeatureinfo", this, showInfo);
				map.addControl(infoControls[i]); 
			}

			map.addControl(new OpenLayers.Control.LayerSwitcher());
			infoControls.click.activate();
			map.zoomToMaxExtent();
			map.addControl(new OpenLayers.Control.MousePosition());
		}

		function showInfo(evt) {
			if (evt.features && evt.features.length) {
				highlightLayer.destroyFeatures();
				highlightLayer.addFeatures(evt.features);
				highlightLayer.redraw();
			} else {
				document.getElementById('responseText').innerHTML = evt.text;
			}
		}
В ответе chrome выдает

Код: Выделить всё

<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.0.0" maxFeatures="10" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd">
<wfs:Query typeName="feature:green">
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:BBOX><ogc:PropertyName>mygeom</ogc:PropertyName>
<gml:Box xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:28412">
<gml:coordinates decimal="." cs="," ts=" ">12655892.568359,6667240.0429688 12656182.626953,6667530.1015625</gml:coordinates>
</gml:Box>
</ogc:BBOX>
</ogc:Filter>
</wfs:Query>
</wfs:GetFeature>
В созданных слоях select и hover ничего не происходит

Запрос на атрибуты работает корректно