[Cartoweb-users] Cartoweb and Ajax

Oliver Christen oliver.christen at camptocamp.com
Mon Jul 23 05:02:42 EDT 2007

The problem is some event are not handled in the same way, so simply faking 
a post via ajax will not effectively trigger the event.
And also Im not even talking about the returned value(s) which are not 
formated in the same way.

For the fullextent, this was already discussed :

For mapsize, the idea is the same, but a bit more complicated, as there are 
more element in the template that must be updated.
The mapsize change is intercepted in the "images" coreplugin. What you 
should do is :
- change the mapsize template so the change trigger an ajax action (look at 
other template for example),
- add new functions in images.ajax.js to update the corresponding elements 
in the page with the new values. Simply look in the templates files 
(cartoclient.tpl and maybe others) where the variables returned by the 
images coreplugin (you can see these in function renderFormPrepare) are used 
and do the same but with javascript.
I dont think you need to modify the ClientImages.php, as it already contain 
the corresponding ajax related functions.


> Hi
> Thank for your answer. The functionnalities i need in ajax are fullExtent 
> and mapSize.
> Well by now i'm trying to implement it on the full extent function. Maybe 
> you could tell me wether i took a wrong path.
> On the doSubmit function, instead of the myform.submit(); i do a 
> x_submitForm(); wich looks like this:
> /function x_submitForm(){
>  xShow(xGetElementById('loadbarDiv'));
>  var param = AjaxHandler.buildPostRequest();
>  var laRequete = new Ajax.Request('/cw/htdocs/x_aeag.php', {method: 
> 'post',parameters: param,onComplete: afficherReponse} );
> }
> /The file x_aeag.php looks like this:
> /<?php
> $_ENV['CW3_PROJECT'] = 'aeag';
> require_once('client.php');
> header('Content-Type: text/xml');
> ?>/
> And then i modified the cartoclient.tpl so it produces an xml stream:
> /<?xml version="1.0" encoding="UTF-8"?>/
> /<reponse>
>    <bbox>{$bboxMinX},{$bboxMinY},{$bboxMaxX},{$bboxMaxY}</bbox>
>    <factor>{$factor}</factor>
>    <mapunits>{$mapUnits}</mapunits> 
> <scalebarUnits>{$scalebarUnits}</scalebarUnits>
>    <currentScale>1:{$currentScale}</currentScale>
>    <mainmap_path>{$mainmap_path}</mainmap_path>
>    <mainmap_width>{$mainmap_width}</mainmap_width>
>    <mainmap_height>{$mainmap_height}</mainmap_height>
>    <scalebar_path>{$scalebar_path}</scalebar_path>
>    <keymap_path>{$keymap_path}</keymap_path>
> </reponse>/
> Now my problem is that cartoweb doesn't produce the full extent map image. 
> A new image is yet generated but with still the same extent. I can't find 
> why...
> regards
> Simon Ortet
> Oliver Christen a écrit :
>> Hi
>> Some plugins and maybe some core functionnalities are not compatible with 
>> ajax.
>> Simply changing the doSubmit function to only return xmlhttprequest 
>> (ajax) is probably not a good idea as it will break in the cases said 
>> above.
>> I would suggest to first identify precisely which functionnalities you 
>> use are still using non-ajax mode and then see how to modify these 
>> functionnalities so they work with ajax (if possible)
>> regards
>> Oliver
>> ----- Original Message ----- From: "Simon ORTET" <simon.ortet at silogic.fr>
>> To: <cartoweb-users at lists.maptools.org>
>> Sent: Thursday, July 19, 2007 10:25 AM
>> Subject: [Cartoweb-users] Cartoweb and Ajax
>>> Hi,
>>> I'm trying to set Cartoweb as a full Ajax application. So i try to 
>>> change the doSubmit function of dhtmlInit.js to make it send the form 
>>> through an ajax function.
>>> I'd like to know if someone as already done this work, and if possible 
>>> to post the code in the list.
>>> Thanks
>>> _______________________________________________
>>> 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