[Cartoweb-users] writing new plugin

Alexandre Saunier alexandre.saunier at camptocamp.com
Thu Mar 2 04:16:41 EST 2006


The tutorial aims to be quite simple, so it assumes there is only one 
search result.

To be more realistic (possibly several search results):
- modify the makeSearch() method to make it return an array of results
- add a check in filterPostRequest() to detect if there is more than 1 
result
- if one result => perform the recentering as already coded
- if several results => zap the recentering and simply display a drop 
down list of results (using the renderForm() method and adapted smarty 
templates) in the user interface

At next page, if an item from the latter drop down list is detected 
(within filterPostrequest()), perform a recentering using quite the same 
mechanism than already described.

handleHttpGetRequest() is helpless in that case.


oliver wrote:
> what we usualy do in such case is a search plugin that is not linked to 
> the query plugin and only display the list of possible choice. This make 
> it much more simple than trying to extent the query plugin which is 
> quite complex.
> You probably only need to use the 
> function handleHttpGetRequest($request) to retrieve the search parameter 
> and query the db and renderForm(Smarty $template) for generating the 
> list of rencenter links and displaying it in the template. To intercept 
> the recenter, well, i thing you already did a recenter plugin based on 
> the wiki exemple.
>  
> that should be quite straitforward
>  
> Regards,
> Oliver
> 
>     ----- Original Message -----
>     *From:* giuseppe.derossi at email.it <mailto:giuseppe.derossi at email.it>
>     *To:* cartoweb-users at lists.maptools.org
>     <mailto:cartoweb-users at lists.maptools.org>
>     *Sent:* Wednesday, March 01, 2006 11:33 PM
>     *Subject:* Re: [Cartoweb-users] writing new plugin
> 
> 
> 
>      Hi guys,
>     that's perfect. The plugIn is OK. The interaction with other plugins
>     is complete.
> 
>     Now, I'm working to resolve this situation: I insert a name in my
>     new research plugin, and I get more than a choice from my
>     database, I'd like to see a linkable list of my results so when I
>     click on one of them the map is recentered: is there anybody who has
>     solved it ? do you advice me to modify the query plugin , other info ?
> 
>     Thanks and regards
> 
>     Giu
> 
> 
>         --------- Original Message --------
>         Da: giuseppe.derossi at email.it
>         To: "Alexandre Saunier" <alexandre.saunier at camptocamp.com>,
>         "yves.bolognini at camptocamp.com" <yves.bolognini at camptocamp.com>
>         Cc: cartoweb-users at lists.maptools.org
>         Oggetto: Re: [Cartoweb-users] writing new plugin
>         Data: 01/03/06 12:22
> 
>         Hi all,
> 
>         To tell the true, I' ve supposed that, so in my last attemp,
>         last night, I wrote the lines as you focused but I get such a
>         syntax error; the lack of attention ?
>         .... to me,  the .tpl file too should be different if u want to
>         recenter by setting the found coordinates, shouldn't it ?
>          
>         Giu
> 
> 
>             --------- Original Message --------
>             Da: "Alexandre Saunier" <alexandre.saunier at camptocamp.com>
>             To: "yves.bolognini at camptocamp.com"
>             <yves.bolognini at camptocamp.com>
>             Cc: cartoweb-users at lists.maptools.org
>             Oggetto: Re: [Cartoweb-users] writing new plugin
>             Data: 01/03/06 11:28
> 
> 
> 
>             Oops! You're right Yves: there was a typo in the tutorial
>             (now fixed).
>             Please read
>             $request->setValue('recenter_x', $x);
>             $request->setValue('recenter_y', $y);
>             instead of
>             $this->request->setValue('recenter_x', $x);
>             $this->request->setValue('recenter_y', $y);
>             in the last filterPostRequest() definition.
> 
>             Yves Bolognini wrote:
>              > Hi Giuseppe,
>              >
>              > On your (1) and (2) lines, you use
>             $this->request->setValue(). Don't you
>              > mean $request->setValue()?
>              >
>              > Regards,
>              > Yves
>              >
>              >
>              > On mer, 2006-03-01 at 10: 13 +0100,
>             giuseppe.derossi at email.it <mailto:giuseppe.derossi at email.it>
>             wrote:
>              >
>              >>Hi Oliver,
>              >>Yes, there is the "implements FilterProvider ", regarding
>             your
>              >>advising, I can see $x and $y in the code below: if I
>             substitute lines
>              >>(1) and (2) by "echo $x,$y", olnly for testing, I can
>             read the right
>              >>coordinates values. Must I do anything else ?
>              >>
>              >>Thanks in advantage.
>              >>
>              >>Ps: I'm translating the messages in Italian language, I'd
>             like to
>              >>facilitate the spreading of this powerful product, I can send
>              >>the .po files if you like .
>              >>
>              >>
>              >>
>              >> --------- Original Message --------
>              >> Da: "oliver" <oliver.christen at camptocamp.com>
>              >> To:
>              >> Cc: cartoweb-users at lists.maptools.org
>             <mailto:cartoweb-users at lists.maptools.org>
>              >> Oggetto: Re: [Cartoweb -users] writing new plugin
>              >> Data: 01/03/06 10:23
>              >>
>              >> Hi Giuseppe,
>              >>
>              >> did you add "implements FilterProvider " in your plugin
>             class
>              >> definition ? Otherwise your plugin wont understand what are
>              >> filterGetRequest and filterPostRequest
>              >>
>              >> otherwise, try doing a x($request) in your filterPostRequest
>              >> function to see whats inside and eventually see if something
>              >> is wrong.
>              >>
>              >> Regards,
>              >> Oliver
>              >> ----- Original Message -----
>              >> From: giuseppe.derossi at email.it
>             <mailto:giuseppe.derossi at email.it>
>              >> To: oliver
>              >> Cc: cartoweb-users at lists.maptools.org
>             <mailto:cartoweb-users at lists.maptools.org>
>              >> Sent: Wednesday, March 01, 2006 9:03 AM
>              >> Subject: Re: [Cartoweb-users] writing new plugin
>              >>
>              >>
>              >> Hi,
>              > > I fixed the first error, due to a naming error. Now,
>              >> the plug in is found but I get the following error:
>              >>
>              >> Class : CartocommonExceptionMessage : Error [8,
>              >> Undefined property: ClientRicerca::$request, C:\wamp
>              >> \www\cartoweb3\projects\MyProject\plugins\Ricerca
>              >> \client\ClientRicerca.php, 21]
>              >>
>              >>
>              >> My target consists on building up a new recenter
>              >> plugin. I've followed the indications into
>              >> HowToWriteANewRecenterPlugIn. This new plugin gets a
>              >> text string (name of a building and so on) and
>              >> recenters the map on the specific point. In a db,
>              >> there is the relation between name and coordinates.
>              >> I've created a new folder and put the template into
>              >> it, and that is ok, the plugin find the coordinates
>              >> but than it crashes and returns the error above.
>              >> That is my code :
>              >>
>              > >
>              >> public function filterGetRequest(FilterRequestModifier
>              >> $request) {}
>              >>
>              >> public function
>              >> filterPostRequest(FilterRequestModifier $request) {
>              >> $searchString = $request->getValue('buildName');
>              >> if (!empty($searchString)) {
>              >>
>              >> // To simplify we assume that only one result
>              >> is returned by the search
>              >> list($x, $y) =
>              >> $this->makeSearch($searchString);
>              >>
>              >> $this->request->setValue('recenter_x', $x);
>              >> (1)
>              >> $this->request->setValue('recenter_y', $y);
>              >> (2)
>              >>
>              >> }
>              >>
>              >> protected function makeSearch($searchString) {
>              >> // db connection atc.
>              >>
>              >> return array($x, $y);
>              >>
>              >> }
>              >>
>              >> If I delete the lines (1) and (2) there's no error
>              >> but I don' t get the recentering. Can y ou help me?
>              >> Is there a way to set a fixed zoom so I get a visible
>              >> map in a time ?
>              >>
>              >> In my not-smarty plugin, I've set the distances for x
>              >> and y to set a fixed box around the found center.
>              >>
>              >> Thanks in advantage
>              >>
>              >>
>              >> --------- Original Message --------
>              >> Da: "oliver" <oliver.christen at camptocamp.com>
>              >> To:
>              >> Cc: cartoweb-users at lists.maptools.org
>             <mailto:cartoweb-users at lists.maptools.org>
>              >> Oggetto: Re: [Cartoweb-users] writing new
>              >> plugin
>              >> Data: 27/02/06 09:06
>              >>
>              >> Hi Giuseppe,
>              >> first, be sure you didnt used any function
>              >> that require a server side ( your plugin must
>              >> not implements ServerCaller),
>              >> also you must not call your plugin on the
>              >> server side (in
>              >> server_conf/yourproject/yourproject.i ni it
>              >> must not be in loadPlugins = ...)
>              >> otherwise it may be something to do with the
>              >> functions or objects you have used but i cant
>              >> say without seeing your actual code.
>              >>
>              >> Regards,
>              >> Oliver
>              >>
>              >> ----- Original Message -----
>              >> From: giuseppe.derossi at email.it
>             <mailto:giuseppe.derossi at email.it>
>              >> To: Alexandre Saunier
>              >> Cc: cartoweb-users at lists.maptools.org
>             <mailto:cartoweb-users at lists.maptools.org>
>              >> Sent: Sunday, February 26, 2006 11:40
>              >> PM
>              >> Subject: Re: [Cartoweb-users] writing
>              >> new plugin
>              >>
>              >>
>              >> Hi Alexandre,
>              >> in my first attemp, I wrote a new
>              >> feature by linking a new html/php
>              >> page in the main page, the results is
>              >> ok but it's no too "s marty", then I've
>              >> just tried to follow the suggested
>              >> procedures,
>              >> HowToWriteaRecenterPlugin, Ive
>              >> called my new plugin myPlugin (what a
>              >> immagination ), but when I recall my
>              >> project (which works fine
>              >> in Cartoweb 3.2 ) I get :
>              >>
>              >> Couldn't load plugin ServerMyPlugin.
>              >>
>              >> No errors during the compilation. I've
>              >> not written any server plugin, but it
>              >> seems I 'm not supposed to do .
>              >> what's wrong ?
>              >>
>              >> Thanks in advantage.
>              >>
>              >>
>              >>
>              >>
>              >>
>              >>
>              >> --------- Original Message
>              >> --------
>              >> Da: "Alexandre Saunier"
>              >> <alexandre.saunier at camptocamp.com>
>              >> To:
>              >> Cc:
>              >> cartoweb-users at lists.maptools.org
>             <mailto:cartoweb-users at lists.maptools.org>
>              >> Oggetto: Re: [Cartoweb-users]
>              >> wri ting new plugin
>              >> Data: 21/02/06 13:50
>              >>
>              >>
>              >>
>              >> Hello,
>              >>
>              >> have a look at this tutorial:
>              >> http://cartoweb.org/cwiki/HowToWriteaRecenterPlugin
>              >>
>              >> The plugin writing principles
>              >> are obviously the same for
>              >> other kinds of
>              >> plugins...
>              >>
>              >> AS
>              >>
>              >>
>              >>
>              >>
>              >> ----
>              >> Email.it, the professional e-mail,
>              >> gratis per te: clicca qui
>              >>
>              >> Sponsor:
>              >> Campioni GRATIS: Più di 6 milioni di
>              >> persone si sono affidate a VistaPrint
>              >> Scopri perché.
>              >> Clicca qui
>              >>
>              >>
>              >>
>              >> ______________________________________
>              >>
>              >> _______________________________________________
>              >> Cartoweb-users mailing list
>              >> Cartoweb-users at lists.maptools.org
>             <mailto:Cartoweb-users at lists.maptools.org>
>              >> http://lists.maptools.org/mailman/listinfo/cartoweb-users
>              >>
>              >>
>              >>
>              >> ----
>              >> Email.it, the professional e-mail, gratis per te:
>              >> clicca qui
>              >>
>              >> Sponsor:
>              >> Scopri come proteggere dai virus il tuo computer e
>              >> come eliminare ogni tipo di virus! - clicca qui
>              >> Clicca qui
>              >>
>              >>
>              >>
>              >>
>              >>
>              >>----
>              >>Email.it, the professional e-mail, gratis per te: clicca qui
>              >>
>              >>Sponsor:
>              >>DA NON PERDERE: Prova gratis per 15 giorni DVDNet Rent e
>             ricevi a casa
>              >>tua i migliori f ilm!
>              >>Clicca qui
>              >>
>              >>
>              >>_______________________________________________
>              >>Cartoweb-users mailing list
>              >>Cartoweb-users at lists.maptools.org
>              >>http://lists.maptools.org/mailman/listinfo/cartoweb-users
>              >
>              >
>              > _______________________________________________
>              > Cartoweb-users mailing list
>              > Cartoweb-users at lists.maptools.org
>             <mailto:Cartoweb-users at lists.maptools.org>
>              > http://lists.maptools.org/mailman/listinfo/cartoweb-users
>             _______________________________________________
>             Cartoweb-users mailing list
>             Cartoweb-users at lists.maptools.org
>             <mailto:Cartoweb-users at lists.maptools.org>
>             http://lists.maptools.org/mailman/listinfo/cartoweb-users
> 
> 
>         ----
>         Email.it, the professional e-mail, gratis per te: clicca qui
>         <http://www.email.it/cgi-bin/start?sid=3>
> 
>         Sponsor:
>         Email.it Phone Card: chiami in tutto il mondo a tariffe
>         imbattibili da tutti i telefoni fissi e cellulari! Clicca e
>         scopri come
>         Clicca qui
>         <http://adv.email.it/cgi-bin/foclick.cgi?mid=2686&d=20060301>
> 
> 
>         ------------------------------------------------------------------------
> 
>         _______________________________________________
>         Cartoweb-users mailing list
>         Cartoweb-users at lists.maptools.org
>         <mailto:Cartoweb-users at lists.maptools.org>
>         http://lists.maptools.org/mailman/listinfo/cartoweb-users
> 
> 
>     ----
>     Email.it, the professional e-mail, gratis per te: clicca qui
>     <http://www.email.it/cgi-bin/start?sid=3>
> 
>     Sponsor:
>     Campioni GRATIS: Più di 6 milioni di persone si sono affidate a
>     VistaPrint Scopri perché.
>     Clicca qui
>     <http://adv.email.it/cgi-bin/foclick.cgi?mid=4833&d=20060301>
> 
>     ------------------------------------------------------------------------
> 
>     _______________________________________________
>     Cartoweb-users mailing list
>     Cartoweb-users at lists.maptools.org
>     http://lists.maptools.org/mailman/listinfo/cartoweb-users
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> 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