Using Javascript to update maps in a web page

Martin Weinelt mweinelt at PLANIGLOBE.COM
Mon Nov 15 08:50:44 EST 2004


On Sunday 14 November 2004 15:09, Daniele Margotti wrote:
> Hi,
> I have a question about using Javascript to update maps in a web page.
>
> If I don't want to reload the page every time I request a new map, I can
> use javascript to re-create - on the fly - only objects that change, for
> instance "map" (using: img src="/cgi-bin/mapserv?mode=map...."), "scalebar"
> (using: img src="/cgi-bin/mapserv?mode=scalebar....") and "reference"
> (using: img src="/cgi-bin/mapserv?mode=reference....").
>
> When I use MapServer CGI, some variables (current scale, current
> extent, ...) are automatically updated by MapServer that substitutes the
> field name (e.g.: [scale]) in the template.
>
> Can I obtain these values from MapServer only using Javascript?
> I think I cannot calculate these values with Javascript functions because
> MapServer, when creates a map, modifies the requested extent (and,
> consequently, the scale) adjusting it on the base of pixel size, right?
> So... Is there a "mode" in MapServer that outputs, instead of a
> map/scalebar/reference image, a value (for current scale or current extent)?

Daniele,

I used a hidden frame where only the the dynamic content got loaded
(map, reference map, extent values, legend, etc) via a template.
The hidden frame  fired a javascript of the main (interface) frame
"on load", which copied the images and values from the hidden frame
into the interface frame.

Now that frames are more and more disliked you can setup something
similar with the use of iframes. You work on iframe documents as if they
were documents in another window. See W3C DOM documentation for
more info.

There is a nice introduction on using iframes to set up a RPC like
architecture on
" http://developer.apple.com/internet/webcontent/iframe.html "
Yes, it is developer.apple.com ... ;-)

There is a bit browser sniffing in the sample code which I dislike
(browser sniffing is dead), but you get an idea how to handle
cross browser issues nowadays at the same forum:

http://developer.apple.com/internet/webcontent/objectdetection.html

introduces you to object/property/method detection

Ehm ... , I not working for Apple.

Cheers, Martin


--
 --- Martin Weinelt
 --- kk+w - digital cartography
 --- Kiel, Germany
 --- Tel: +49.431.5791165
 --- http://www.planiglobe.com



More information about the mapserver-users mailing list