piero.cavalieri at GMAIL.COM
Fri Jul 6 13:19:31 EDT 2007
me to give, also if it few lines of code...). However idea is that u could
collect relevant values from user interface (the web page) which u need to
build a new map (for example the list of layers, the current map extent
which is returned by mapserver itself in the [mapextent] template variable,
ecc...) and build a correct request for mapserver.
The list of layers and other key elements for the request, u take via
var layersString = getLayers(); //this call a function which cicle on the
layers list and takes only those the user want.
imgext = document.getElementById("imgext").value;
imgbox = document.getElementById("imgbox").value; //setted by dbox/jbox
imgxy = document.getElementById("imgxy").value; //setted by dbox/jbox
Than u build request for Mapserver, for example:
5000123.4 1620003.7 5010567.9&imgbox=143 200 200 255&imgxy=143
This request u need to pass mapserver cgi without doing a POST, otherwise u
have a page reload. For doing this, I have used an Ajax library which,
without doing a POST, let me to call a server side (.NET) function from a
signature, but without the retrieveMapImage_callback parameter). Details
managed by the ajax library I used (and if u use other libraries, things
will be different), important thing is that there is no page reload in this
retrieveMapImage_callback function is invoked. What I do in this function ?
It update map elements:
document.getElementById("mapwidth").value = res.value.mapwidth;
document.getElementById("mapheight").value = res.value.mapheight;
document.getElementById("imgxy").value = res.value.imgxy;
document.getElementById("imgext").value = res.value.imgext;
document.getElementById("legend").innerHTML = res.value.legend;
document.getElementById("scale").value = res.value.scale;
imgMap.src = res.value.mapImgUrl;
imgRef.src = res.value.referenceMap;
imgScalebar.src = res.value.scalebar;
But how can I have in server side, new values based on the request above ?
I use an
System.Net.HttpWebRequest (this one is .NET, Java should have a similar
HttpWebRequest webRequest = (HttpWebRequest) WebRequest.Create(queryString);
And what's the response? In the .map file I specified to use a particular
TEMPLATE "templates/web_template.xml" which is:
<?xml version="1.0" encoding="utf-8" ?>
Normally, when u use Mapserver in cgi mode, u have the html page which
contains those template parameters (  ). The html page do a POST,
mapserver substitute parameters in the page with new values and the page is
sent back to the client.
Here is different. The template is processed and remains on the server. You
parse the response of the HttpWebRequest, and create an object to send to
the client (the response to the Ajax call). Then the client update the page
as I explained above.
With Java, I think u colud use a library called DWR (Direct Web Remoting),
which is conceptually similar to the AjaxPro I used (both are free).
Note this is only a method I used, but u could do things in different ways
(u could study some php framework). Also I used MapServer in cgi mode. Maybe
u want to use Java Mapscript, so things will be different.
2007/7/5, LITTLE Nelson <nelson.little at tenix.com>:
> Thanks for your reply it was the only one I got. You mentioned a lot of
> new technologies so I am not sure what to use.
> Currently my web page is one big HTML form. I was thinking that maybe when
> the user clicks on 'Redraw Map' button then that button could call some
> do that?
> *From:* Piero Cavalieri [mailto:piero.cavalieri at gmail.com]
> *Sent:* Wednesday, 4 July 2007 5:25 PM
> *To:* LITTLE Nelson
> *Cc:* MAPSERVER-USERS at lists.umn.edu
> *Subject:* Re: [UMN_MAPSERVER-USERS] Architectural Question
> You could use iframe or ajax ways. I used AjaxPro with.NET and cgi
> Mapserver and I don't have a single page refresh (everything is updated in
> background: map, scalebar, legend, query results). If u use Java, I think u
> coluld try DWR (Direct Web Remoting). Seems to remember that JBox is more
> suitable to use with Ajax, but try some ways.
> 2007/7/4, LITTLE Nelson <nelson.little at tenix.com>:
> Hello Mapserver users,
> I have developed a web based mapserver application using Java Mapscript &
> Servlets and it works well and looks great. I currently use the Rosa Applet
> as the map window display. My application is very similar in behaviour to
> the Mapserver Atlas application (AKA gmap) (online:
> Whenever the user hits 'Redraw Map' or clicks on a tool button, it causes
> the whole pages to be refreshed. My question is how could this be changed so
> that only the map window is refreshed, not the whole page? I know this is an
> architectural type question which is not really related to Mapserver, but if
> anyone would know the answer it would be the people on this list.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the mapserver-users