Using Javascript to update maps in a web page

Matthew Perry mtperry78 at SBCGLOBAL.NET
Sun Nov 14 10:22:12 EST 2004


Daniele,

There is no way (as far as I know) for mapserver to output such information since mapsver is state-less and wouldn't know which image you were reffering to.

However, you can do it by managing all of the extent information on the client side using javascript. The best solution I've found is Steve Lime's mapserv.js. You can check it out in action at:

http://www.dnr.state.mn.us/maps/landview_dhtml.html

Check out the page source for the URL to mapserv.js and for an example of how it is used (look for the ms.* javascript variables). It really helps with interface development since you're just swapping images instead of reloading the page so you can maintain alot of info a javascript variables. This solution is also nice since you no longer have to deal with temp images being stored on your hard drive.

Matt Perry
Humboldt State University

Daniele Margotti <margottid at COMUNE.LUGO.RA.IT> 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)?


Thank you,
Daniele
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-users/attachments/20041114/f8c2d46b/attachment.html


More information about the mapserver-users mailing list