[Cartoweb-users] mapOverlay cartoweb

Oliver Christen oliver.christen at camptocamp.com
Thu Mar 22 08:05:02 EST 2007


hi Luigi

first you need to recover the submit action. a simple <input type="submit" 
value="ok" /> as you set in your template will simply post the form but 
initiate no action.
give a name to you input <input type="submit" name="specialactiontrigger" 
value="ok" />
if you dont give a name to your input they are simply ignored.

next step is to recover the "specialactiontrigger" in the client part

declare the variable at the beginning of the plugin:

protected $specialactiontrigger;

to do so use the handleHttpPostRequest($request) function, like this:

handleHttpPostRequest($request) {
    if (isset($request['specialactiontrigger']) {
        $this->specialactiontrigger = true;
    } else {
        $this->specialactiontrigger = false;
    }
}

you need to put something in the buildRequest() { } function, otherwise the 
server part will not be called
something like :

    public function buildRequest() {
        if ($this->specialactiontrigger) {
            return $this->specialactiontrigger;
        }

    }

then, on the server part:

    protected $specialactiontrigger;

    public function initializeRequest($requ) {
        if ($requ) {
            $this->specialactiontrigger = $requ;
        }
    }

and finally

public function handlePreDrawing($request){
  if (isset($this->specialactiontrigger ) {
    $msMapObj = $this->serverContext->getMapObj();
    $layer = new LayerOverlay();
    $layer->action = BasicOverlay::ACTION_INSERT;
    $layer->name = "mappa";
    $layer->data = "images/cc_20050603.tif";
    $mapOverlay = $this->serverContext->getPluginManager()->mapOverlay;
    $mapOverlay = updateMap($layer);
    $this->serverContext->getMapObj()->save('debug.map');
  }
}

you notice its like a chain of events: 
input->handleHttpPostRequest->buildRequest->//->initializeRequest->handlePreDrawing

see http://www.cartoweb.org/doc/misc/plugins_diagram.pdf to understand the 
flow of events in Cartoweb

Regards
Oliver

----- Original Message ----- 
From: "Luigi.marotta" <luigi.marotta at email.it>
To: <cartoweb-users at lists.maptools.org>
Sent: Thursday, March 22, 2007 8:04 AM
Subject: [Cartoweb-users] mapOverlay cartoweb


>
> Salve a tutti,
> sto usando CartoWeb ed ho la necessità di rendere
> modificabile, al volo, un raster. Ho implementato un plugin per modificare
> il campo "data" di un raster.
> Client:
> <?php
> /**
> * ClientDataMappa.php
> */
>
> class ClientDataMappa extends ClientPlugin
> implements GuiProvider, serverCaller {
>
> /**
> * GuiProvider methods
> */
> public function handleHttpPostRequest($request) {}
> public function handleHttpGetRequest($request) {}
>
> public function buildRequest() {}
> //public function renderForm(Smarty $template) {}
>
> protected function drawUserForm() {
> $smarty = new Smarty_Plugin($this->getCartoclient(), $this);
> return $smarty->fetch('dataInput.tpl');
> }
>
> public function renderForm(Smarty $template) {
> $template->assign('dataInput', $this->drawUserForm());
> }
>
> public function initializeResult ($request){}
> public function handleResult($request){}
>
>
> }
> ?>
>
> Template:
> <!-- dataInput.tpl -->
> <input type="submit" value="ok" />
>
> Server:
> <?php
> class ServerDataMappa extends ClientResponderAdapter {
> //public function updateMap(BasicOverlay $overlay){
> public function handlePreDrawing($request){
> $msMapObj = $this->serverContext->getMapObj();
> $layer = new LayerOverlay();
> $layer->action = BasicOverlay::ACTION_INSERT;
> $layer->name = "mappa";
> $layer->data = "images/cc_20050603.tif";
> $mapOverlay = $this->serverContext->getPluginManager()->mapOverlay;
> $mapOverlay = updateMap($layer);
> $this->serverContext->getMapObj()->save('debug.map');
> }
> }
> ?>
>
> Il template presenta solo un pulsante che dovrebbe richiamare la parte
> server per modificare il raster ma non funziona ed anche se lascio il 
> campo
> data vuoto o vi inserisco un indirizzo inesistente non ottengo nessun
> cambiamente. Dove sbaglio!
> Grazie a tutti anticipatamente
>
> Luigi
> --
> Email.it, the professional e-mail, gratis per te: http://www.email.it/f
>
> Sponsor:
>
> Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=6119&d=20070322
>
>
> _______________________________________________
> Cartoweb-users mailing list
> Cartoweb-users at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/cartoweb-users
> 



More information about the Cartoweb-users mailing list