[OpenLayers-Users] What is the easiest way to search a vector layer(s)?

boesiii boesiii at yahoo.com
Thu Feb 28 11:42:35 PST 2013


I am having a problem with getting the layer name.  When I run the code I get
an error "Cannot read property 'features' of undefined", obviously because
it is not getting the layer name.

.....html......
<form name="myform" action="" method="GET">
            <input type="hidden" name="layer" value="mh_layer">
            <input TYPE="button" NAME="button" Value="Search"
onClick="searchTest(this.form)"> 
        </form>
....html.....


function searchTest () {
             layer = map.getLayersByName(form.layer.value)[0];
            searchVector(layer,keyword); 
            
        }

var map, select;

 function init(){
    map = new OpenLayers.Map('map', {
                units: 'm',
                numZoomLevels: 19,
                projection: epsg900913,
                displayProjection: epsg4326 //Is used for displaying
coordinates in appropriate CRS by MousePosition control
            });


     var mh_layer = new OpenLayers.Layer.Vector("Manhole", {
                searchfields: [ 'STRUCT_ID', 'OWNER_NAME', 'GPS_DATE' ], 
                titlefield: 'STRUCT_ID', 
               strategies: [new OpenLayers.Strategy.Fixed()],
                protocol: new OpenLayers.Protocol.HTTP({
                    
                    url: "./mh.geojson",
                    format: new OpenLayers.Format.GeoJSON({
                        extractStyles: true,
                        extractAttributes: true
                    })
                })
            });



--
View this message in context: http://osgeo-org.1560.n6.nabble.com/What-is-the-easiest-way-to-search-a-vector-layer-s-tp5036948p5037574.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.


More information about the Users mailing list