1

I have implemented a search functionality for a vector layer in openlayers 2.13.1. I use CQL.

I take the values from an html form and I use javascript to pass them to a CQL filter and execute it.

Works fine in Chrome 31.0.1650.63 and Firefox 25.0.1. But not in Internet Explorer 11. Was working in IE10, not in IE 11.

I search for some features and I know that should show features, but nothing shows on the map.

I hit map.layers[2].features on IE11's console and I get [functions], __proto__, layer, renderIntent and length is 1 but, no fid, no geometry.

Also, if I hit refresh in the page, in IE11 console I get The object does not support the property or method 'destroy' (translated from Greek, see screenshot).

Here is my code

    //fallback html5 websockets with flash -libraries
    <script type="text/javascript" src="swfobject.js"></script>
    <script type="text/javascript" src="web_socket.js"></script>

    <script src="jquery-1.8.2.min.js"></script> 

    //polyfiller for html5 elements
    <script src="js-webshim/minified/extras/modernizr-custom.js"></script> 
    <script src="js-webshim/minified/polyfiller.js"></script> 
        <script>    
          $.webshims.polyfill();    
        </script> 

    //polyfiller for css3 media queries
    <script src="../respond.src.js"></script>

    <script src="http://maps.google.com/maps/api/js?sensor=false"></script>

    <script type='text/javascript' src='OpenLayers.js'></script>

    <script type='text/javascript'>

    function init(){//called with body onlad, inits map, layers etc.
      //init the layer
      pins = new OpenLayers.Layer.Vector("Pins", {renderers: ["Canvas", "SVG", "VML"]})

      //set index
      map.setLayerIndex(pins, 70);

      //set styles for pins layer
      var vector_style_map = new OpenLayers.StyleMap({'default': style_d,'select': style_select});
      pins.styleMap = vector_style_map;

    }

   //called when the search button of the form is clicked 
   function zoomSearch(){

      //"clean" layer first
      pins.removeFeatures(pins.features);
      pins.refresh({force:true});

      //set array
      var filter_list = [];

      //take the values
      if (document.getElementById("nm").value != "") {
        var filter_c = new OpenLayers.Filter.Comparison({
            type: OpenLayers.Filter.Comparison.LIKE,
            property: 'p_name', 
            value: '%'+document.getElementById("nm").value+'%'
        });
        filter_list.push(filter_c);}

      if (document.getElementById("descr").value != "") {
        var filter_d = new OpenLayers.Filter.Comparison({
            type: OpenLayers.Filter.Comparison.LIKE,
            property: 'p_descr', 
            value: '%'+document.getElementById("descr").value+'%'
        });
        filter_list.push(filter_d);}

      //create the final filter,combining the above,  to search
      var filter_final = new OpenLayers.Filter.Logical({
        type: OpenLayers.Filter.Logical.AND,
        filters: filter_list});

      //pass the filter to the layer
      var prot =  new OpenLayers.Protocol.WFS({
        url:  "http://localhost/geoserver/wfs",
        featureType: "pins",
        featureNS: "http://www.mysite.gr",
        defaultFilter: filter_final});

      var _CallBack = function(resp) {
          pins.addFeatures(resp.features)
         var cb = pins.features.length;
          if (cb == 0){alert"nothing. try again";}
          if(cb==1){map.zoomToExtent(pins.getDataExtent());   map.zoomTo(8);}
         else{map.zoomToExtent(pins.getDataExtent());}
        };


      var response = prot.read({callback: _CallBack});  

      //refresh to render POIs
      pins.refresh({force:true});

    }

How can I fix this? Is it me or is it a bug?

Thanks in advance

enter image description here

  • I think its a bug (or perhaps, multiple bugs). See github.com/openlayers/openlayers/issues/1177 and osgeo-org.1560.x6.nabble.com/WFS-and-IE-11-td5090636.html for a possible workaround. Does that match what you are seeing? – BradHards Dec 11 '13 at 1:50
  • @BradHards I think the osgeo link is more close to my problem. But they talk about XML format and I use just WFS format. Correct me if I am wrong here. Not so much experienced with this stuff. – slevin Dec 11 '13 at 2:09
  • WFS queries are normally in XML. What does Firebug show you? – BradHards Dec 11 '13 at 2:46
  • 1
    At the end of the above osgeo.org post Stephen Battey posted some Format.XML code. Put that in a .js file and load it after you load OpenLayers.js. I am pretty sure it will fix your problem. It worked for me. My code is similar to yours. – Ralph Dell Dec 11 '13 at 13:27
  • I believe it is a ie11 bug rather than an OpenLayers bug. – Ralph Dell Dec 11 '13 at 15:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.