Thanks, I am trying to get this.
Even if I change the createLayer function I am still confused as to
the layer name:
function createWmsLayer(name, url, params, options) {
var layer = new OpenLayers.Layer.WMS(name, url, params, options)
map.addLayer(layer);
return layer;
};
createWmsLayer("<span class='locc'>Ikke listet</span>",
"http://localhost/geoserver/wms",
{layers: 'gbif_ns:ikke_listet',format:
'image/png', transparent: 'true'}, {singleTile: true, ratio: 1,
isBaseLayer:false,
visibility: false} );
It seems the layer name is now: "<span class='locc'>Ikke
listet</span>". That is the way it is displayed and there may be a
better way to style the menu (that is why I do it that way).
If I understand you correctly I should put the filter params inside
the createWMS function? And run the create function every time I do a
search? All these layers are from one PostGIS DB and filtered in
GeoServer. How about this:
function createWmsLayer(name, url, params, options) {
var layer = new OpenLayers.Layer.WMS(name, url, params, options)
map.addLayer(layer);
return layer;
// get search field value... var searchF =
$('#searchField').val() // query method
// if checkbox is A then cqlParam = "collector", if checbox is
B then cqlParam ="species" ......
filterParams = {
filter: null,
cql_filter: cqlPa LIKE '%" + search + "%' ",
featureId: null
};
};
Am I on the right path? Thanks for helping out :-)
~asle
2012/5/9 Phil Scadden <[email protected]>:
> This is all client side stuff - you would be better placing queries like
> this on the openlayers-users mailing list.
>
> However, looking at your issue.
>> Still I do not know how to call this in my page. In the example above it
>> says:
>> wms_layer.mergeNewParams({'CQL_FILTER':.....
>> Since I am a newbie I don't know how to call my layer. I.ex. I make a
>> layer this way:
>>
>> var createWmsLayer = function(name, url, params, options) {
>> map.addLayer(new OpenLayers.Layer.WMS(name, url, params, options));
>> };
>>
>> createWmsLayer("<span class='locc'>Ikke listet</span>",
>> "http://localhost/geoserver/wms",
>> {layers: 'gbif_ns:ikke_listet',format: 'image/png',
>> transparent: 'true'}, {singleTile: true, ratio: 1, isBaseLayer:false,
>> visibility: false}
>> );
>>
>> So what do I put in the "wms_layer" in the example above?
>>
>> I tried to make a function like this:
>> function CQLfilter(param){
>> filter_list = []
>> filter_list.append("collector LIKE '%H%' ")
>> var cql = ' AND '.join(filter_list)
>> gbif_ns:ikke_listet.mergeNewParams({'CQL_FILTER': "collector LIKE
>> '%H%' "})
>> }
>>
>
> With your factory:
>
> var createWmsLayer = function(name, url, params, options) {
> map.addLayer(new OpenLayers.Layer.WMS(name, url, params, options));
> };
>
> The WMS layer is an anonymous variable. This makes it difficult to do
> other operations on.
>
> One approach would be
>
> function createWmsLayer(name, url, params, options) {
> var layer = new OpenLayers.Layer.WMS(name, url, params, options)
> map.addLayer(layer);
> return layer;
> };
>
> You need the layer object to do other things with.
>
> The CQLfilter doesnt make much sense me. I would pass in the layer object
> from createWmsLayer.
>
> When I add a CQL filter, I do it with
> filterParams = {
> filter: null,
> cql_filter: "collector LIKE '%H%' ",
> featureId: null
> };
> layer.mergeNewParams(filterParams);
>
> where layer is what is returned from createWmsLayer. If you want to stick
> with anomymous layers, then you have to search the layers array of the map
> object for the one you want to apply the CQL too.
>
> --
> 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.
>
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users