[OpenLayers-Users] Re: How to apply a Search Function

Phil Scadden p.scadden at gns.cri.nz
Thu Feb 9 17:51:56 EST 2012


> *Ok ..
> these are my protocol + my vector layer:*
>
> var wfsprotocol = new OpenLayers.Protocol.WFS({
>                     url: "http://IP/geoserver/wfs",
>                     featureType: "myLayer", 	
> 		   featureNS: "http://mapmap.org",
> 		   srsName: "EPSG:3857",
>                     version: "1.1.0",
>                     extractAttributes: true,
>                     isBaseLayer: false,
>                     visibility: true
>                 });
THIS will do a WFS on your layer "mylayer" on the wfs server.
> 			
> 	var VECTOR = new OpenLayers.Layer.Vector("vector", {
> 				maxExtent: new OpenLayers.Bounds(-180, -90,
> 180,90)transform(geographic,mercator),
> 				sphericalMercator: true,
>                                  strategies: [strategy],		//BBOX strategy		
>                                  protocol: wfsprotocol
> 			   });
The vector layer code I gave you was for displaying the results of the 
search. This looks to be
using WFS to display the layer too. I would strongly encourage you to 
display with WMS and query with WFS.

> You might want a layer to display the selected features. eg.
>       selectedLayer = new OpenLayers.Layer.Vector("Selected Layer", {
>
> *So here do I have to create another layer in Geoserver ?
> or it should be my main layer (VECTOR) ?*
This selected layer is going to be populated with selected features 
only. It is in openlayers only, not another geoserver layer.
The idea is that you display the layer with WMS or WFS (preferably WMS). 
Then do your query, clear selectedLayer, and add the results of the 
query to selectedLayer. On the map you will your features but with the 
selected one drawn with the style you have chosen for selectedLayer. ie 
highlighted.

>
>
>
> --
> View this message in context: http://osgeo-org.1560.n6.nabble.com/How-to-apply-a-Search-Function-tp4364140p4380752.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users


-- 
Phil Scadden, Senior Scientist GNS Science Ltd 764 Cumberland St, 
Private Bag 1930, Dunedin, New Zealand Ph +64 3 4799663, fax +64 3 477 5232

Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.



More information about the Users mailing list