[Cartoweb-users] Cartoweb and Ajax
Simon ORTET
simon.ortet at silogic.fr
Mon Jul 23 09:59:09 EDT 2007
Thanks for your help.
I managed to deal with the fullextent.
Concerning mapsizes, it's tricky and here's what i've done:
I modified the handleResponse from Images.ajax.js to update the DOM.
I catch no error but this script is not working. The image map is at
requested size (so no problem in server side) but there's something i
don't understand: in the updateDomElement function, instead of
'style.width' the value of property parameter is 'undoClipping'.
I can't figure out why. I pass a string 'style.width' and i receive
'undoClipping'. But there are no instruction between the call of
updateDomElement and it's first line (i tested in step mode with Firebug).
I didn't find anything on Google neither
Here is what i added in the handleResponse method
// Updates mapsize elements
var mw = pluginOutput.variables.mainmap_width;
var mh = pluginOutput.variables.mainmap_height;
AjaxHandler.updateDomElement('needJsDiv','style.width',mw);
AjaxHandler.updateDomElement('needJsDiv','style.height',mh);
AjaxHandler.updateDomElement('loadbarDiv','style.width',mw);
AjaxHandler.updateDomElement('loadbarDiv','style.height',mh);
AjaxHandler.updateDomElement('map','style.width',mw);
AjaxHandler.updateDomElement('map','style.height',mh);
AjaxHandler.updateDomElement('map_rootLayer','style.width',mw);
AjaxHandler.updateDomElement('map_rootLayer','style.height',mh);
AjaxHandler.updateDomElement('map_rootLayer','clip','rect(0pt,
'+mw+'px, '+mh+'px, 0pt)');
AjaxHandler.updateDomElement('map_raster','style.width',mw);
AjaxHandler.updateDomElement('map_raster','style.height',mh);
AjaxHandler.updateDomElement('map_raster','clip','rect(0px,
'+mw+'px, '+mh+'px, 0px)');
AjaxHandler.updateDomElement('map_eventPad','style.width',mw);
AjaxHandler.updateDomElement('map_eventPad','style.height',mh);
AjaxHandler.updateDomElement('map_eventPad','clip','rect(0px,
'+mw+'px, '+mh+'px, 0px)');
AjaxHandler.updateDomElement('map_drawing','style.width',mw);
AjaxHandler.updateDomElement('map_drawing','style.height',mh);
AjaxHandler.updateDomElement('map_drawing','clip','rect(0px,
'+mw+'px, '+mh+'px, 0px)');
Thanks
Simon Ortet
Oliver Christen a écrit :
> 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 :
> http://lists.maptools.org/pipermail/cartoweb-users/2007-February/002058.html
>
> http://lists.maptools.org/pipermail/cartoweb-users/2007-April/002402.html
>
> 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.
>
> regards
> Oliver
>
>
>> 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