[Cartoweb-users] how to change layer selection by code in a plugIn

Oliver Christen oliver.christen at camptocamp.com
Wed Aug 29 04:20:03 EDT 2007


Hi Giuseppe

After looking at the code in ClientLayers, it seems layer_select can only be 
used via GET and not POST, so this wont work that way.
When sending the form via POST, the array list is passed in parameter so you 
should be able to add the layer wanted via filterPostRequest
Try something like that:

public function filterPostRequest(FilterRequestModifier $request) {
    $layerList = $request->getValue('layers');
    $newLayers = 
array('CAR_Group','VIN_layer_1','VIN_layer_2','VIN_layer_2');
    $newLayerList = array_merge($layerList, $newLayers);
    $request->setValue('layers', $newLayerList);
}

By the way, 'recenter_bbox' and 'recenter_scale' are exclusive, its either 
one or another but not both.  'recenter_bbox' calculate automaticaly the 
scale based on the bbox.

And show_crosshair will NOT be triggered when using a 'recenter_bbox', only 
with 'recenter_scale'  or recenter_x/recenter_y

Hope this cover all the issues here.

regards
Oliver


>
>
> Hi Oliver,
> I red the doc, but I was not able to get my target.
> I performed some tests amd I send you my code. Only the recenter option
> works well.
> My plugIn let the user to choose a name of a building which has been
> selected by a quary and linked to recenterBox, so when the user click on
> one
> item of the displayed list of buildings the map is recentered on it.
> I'm working on Cartoweb 3.2 in Win env.I tried to put the values in a
> direct
> mode both with one-quote and double quotes and as int value (for the
> crosshair 1 or '1' or "1" , but nothing ... in $sel_layers there is the
> real
> name of the layer and not the label. I tried both with a group name and
> with
> a list of elementary layers .
> Any suggestion/correction ?
>
> thanks in advance and best regards
>
> Giu
>
> class myNewPlugin extends  ClientPlugin implements  Sessionable,
> GuiProvider, FilterProvider
> {
> ...
>
>  public function filterPostRequest(FilterRequestModifier $request) {
>
> ...
>    $recenterBbox= "$x1, $y1, $x2, $y2";
>    $cross_ok ="1";
>    $sel_layers="CAR_Group,VIN_layer_1,VIN_layer_2,VIN_layer_2";
>
>    $request->setValue('show_crosshair',  $cross_ok);
>    $request->setValue('recenter_scale',  "2000");
>    $request->setValue('recenter_bbox', $recenterBbox);
>    $request->setValue('layer_select',$sel_layers);
>
>
>  }
>
> ...
>
>
> }
>
>  --------- Original Message --------
>  Da: Oliver Christen <oliver.christen at camptocamp.com>
>  To: cartoweb-users at lists.maptools.org <cartoweb-users at lists.maptools.org>
>  Oggetto: Re: [Cartoweb-users] how to change layer selection by code in a
> plugIn
>  Data: 27/08/07 11:24
>
>  >
>> >
>> >
>> > Hi
>> >
>> > maybe you can use the filter layer_select and layer_unselect
>> > see
>> >
>>
> http://www.cartoweb.org/doc_head/docbook/xhtml/dev.newplugin.html#dev.newplugin.special.filters
>> >
>> > regards
>> > Oliver
>> >
>> >
>> >
>> > > Hi,
>> > > I'd like to know if there is a way that forces a layer to be hidden 
>> > > or
>> > > displayed by code ie: I wrote a plugin which returns a list of
> buildings
>> > > which have all a common item,this item is also represented by a 
>> > > layer.
>> Now
>> > > I'd like that on quering into my db, if there are buildings which
>> matches
>> > > an
>> > > item, I can set a layer to be displayed.
>> > > Thanks in advance
>> > > Giu
>> > > --
>> > > Email.it, the professional e-mail, gratis per te:
> http://www.email.it/f
>> > >
>> > > Sponsor:
>> > > In REGALO un GIOCO! Scegli GPBikes 3D,Bubble Boom, Rock City Empire
>> > > Clicca qui:
> http://adv.email.it/cgi-bin/foclick.cgi?mid=6732&d=20070827
>> > >
>> > >
>> > > _______________________________________________
>> > > Cartoweb-users mailing list
>> > > Cartoweb-users at lists.maptools.org
>> > > http://lists.maptools.org/mailman/listinfo/cartoweb-users
>> > >
>> >
>> >
>> >
>> >
>>  --
>>  Email.it, the professional e-mail, gratis per te: http://www.email.it/f
>>
>>  Sponsor:
>>  Entra in Mondolastminute, centinaia di offerte ti aspettano per le tue
>> vacanze a prezzi lastminute!
>>  Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=6851&d=20070828
>>
>>
>>
> --
> Email.it, the professional e-mail, gratis per te: http://www.email.it/f
>
> Sponsor:
> Tutto il merchandising dello SPORT in saldo. Compra CALCIO, MOTO GP,
> FORMULA 1, RUGBY, VOLLEY, TENNIS, CICLISMO. On line adesso.
> Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=6906&d=20070829
>
>
> 



More information about the Cartoweb-users mailing list