mapspork.js
Brent Pedersen
bpederse at NATURE.BERKELEY.EDU
Wed May 3 11:11:16 PDT 2006
hi, i just finished up a project and out of it came what i hope may
be a useful lightweight javascript library for others. i called it
MapSpork, cause it's so simple it doesn't deserve a serious name
it came from an idea here:
http://maps.dnr.state.mn.us/eco/rsg/minnesota/test.html
posted by (i think) David Bitner? MapSpork is an attempt to do that
generically, with html classNames and id's to indicate what the map
or button or any html element should do when clicked/selected/
changed. the library then uses javascript regexp's and such to
manipulate the url to zoom/query/pan as appropriate.
anyway, my crappy testpage and some explanatory text is here:http://
128.32.253.220/mapspork/example.html
and a prettier page gutted from the project here: http://
128.32.253.220/naturetest/
and the javascript as mapspork.js in either of those directories.
works on Firefox, opera, safari and IE 6.
there are 3 classes:
MapSpork. an HTML element with class=MapSpork and id='zoomin' when
selected will indicate that the map should zoomin when clicked (just
like the CGI). likewise for zoomout, and query. these are best as
radio elements.
NameSpork. an element with class=NameSpork and name='layers' when
changed (onchange) or selected (onselect) will cause the map to be
redrawn with whatever values come from layers (just like the CGI).
but since the page is not redrawn, the state is maintained auto.
NameSpork can be use on anything sent into the url.
ClickSpork. ... class=ClickSpork and id='panne' will call the
function MapSpork.panne when clicked. these are best on buttons.
there is not too much functionality as is, because this is about the
extent of my mapserver CGI knowledge, but it's easliy extended by
creating a function MapSpork.whatever = function(){ alert
('whatever') } and
then creating an html element with id='whatever' and the appropriate
Spork class:
<input type='button' id='whatever' class='ClickSpork'>
-brent
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20060503/27fa02ff/attachment.htm>
More information about the MapServer-users
mailing list