将滤镜应用于图层后,对于缩放比较疯狂

时间:2013-11-16 19:28:21

标签: filter openlayers zooming

我知道这个问题已被多次询问过。但是我真的很接近在过滤掉图层后放弃进行这种缩放。

我的代码在这里

function filter(){
        OpenLayers.ProxyHost = "cgi-bin/proxy.cgi?url=";
             var filters = new OpenLayers.Filter.Comparison({
               type: OpenLayers.Filter.Comparison.EQUAL_TO,
               property: "PROVINSI",
               value: document.getElementById("provinsi").value
            });

             var parser = new OpenLayers.Format.Filter.v1_1_0();
             var filterAsXml = parser.write(filters);
             var xml = new OpenLayers.Format.XML();
             var filterAsString = xml.write(filterAsXml);

             wmslayer.params["FILTER"] = filterAsString;
             wmslayer.redraw(true);
             info.vendorParams["CQL_FILTER"] = filter;

            var wfs = new OpenLayers.Layer.Vector(
                    "WFS Features",
                    {
                strategies: [new OpenLayers.Strategy.Fixed()]
                , projection: new OpenLayers.Projection("EPSG:4326")
                , protocol: new OpenLayers.Protocol.WFS({
                    version: "1.1.0",
                    url: "http://localhost:8080/geoserver/ows",
                    featurePrefix: 'rom', //geoserver workspace name
                    featureType: "rom:indonesia", //geoserver Layer Name
                    featureNS: "http://localhost:8080/geoserver/rom", // Edit Workspace Namespace URI
                }),
                filter: filters
            });
            console.log(wfs);

            map.zoomToExtent(wfs.getDataExtent());

        }

过滤功能正常。但我无法放大过滤层。我尝试使用wfs。但是当我调用map.zoomToExtent(wfs.getDataExtent());它缩放到其他地方。

0 个答案:

没有答案