[OpenLayers-Users] OpenLayers search problem, Help!

willphill02 willphill02 at gmail.com
Thu Dec 8 19:40:27 EST 2011


Hi, I'm fairly new to coding, so please bear with me. I can't get the search
function to work on my map. The code for the search function is below:

       var features = [];
	var vecLayer = new OpenLayers.Layer.Vector("Results");
	var select = new GeoExt.grid.FeatureSelectionModel();

	    var protocol = new OpenLayers.Protocol.WFS({
	        url:  "http://localhost:8080/geoserver/wfs",
	        featureType: "location_points",
	        featureNS: "http://www.openplans.org/topp",
	        geometryName: "the_geom"

	    });
	
	    formPanel = new GeoExt.form.FormPanel({
	        title: "Species Search",
	        height: 150,
	        region: "north",
	        protocol: protocol,
	        items: [{
	            xtype: "textfield",
	            width: 200,
	            name: "scientific__like",
	            fieldLabel: "name",
	            allowBlank: false,
	            minLength: 4
	        }],
	        listeners: {
	            actioncomplete: function(form, action) {
	                features = action.response.features;
	                store.loadData(features);
	                vm=map.getLayersByName("Results");
	                if(vm.length==0){
	                    vecLayer = new OpenLayers.Layer.Vector("Results");
	                    map.addLayers(vecLayer);
	                    store.bind(vecLayer);
	                    select.bind(vecLayer);
	                }
	            }
	        },
	        buttons: [{text: 'search',
	            handler: function(){
	                formPanel.search();
	            }
	        }],
	        keys: [{ key: [Ext.EventObject.ENTER], 
	            handler: function() {
	                formPanel.search();
	            }
	        }]
	    });
	    /*formPanel.addButton({
	        text: "search",
	        handler: function() {
	            this.search();
	        },
	        scope: formPanel
	    });

Any help would be much appreciated.

Thanks

--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/OpenLayers-search-problem-Help-tp7076500p7076500.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.


More information about the Users mailing list