[Mapserver-users] how to use HTML Legends with Steve Lime's DHTML interface

Martin Weinelt mweinelt at planiglobe.com
Fri Dec 12 03:52:12 EST 2003


Hello ,

i happen to use DHTML for an HTML-Legend in a current project. I use an DHTML 
API (DynAPI, that is) which takes most of the cross browser issues off my 
back. We do not suport NS4 anymore but Konqueror and Safari.

all Mpaserver generated ouput is sent to a hidden frame an then copied to the 
interface. The hidden frame (called 'mapCache')  has the template. Part of 
the template is a line 
  <input type="hidden" name="legend" value="[legend]">

OnLoad the legend is copied to a layer of the interface (dynLeg). (A widget in 
this case):

dynLeg.setContent(<table 
width=\"100%\">"+top.mapCache.document.forms[0].legend.value+"</table>");

setContent is a DynAPI method to set the content of a layer (some HTML in most 
cases)

Take a look at http://mapserver.pangaea.de/ and if the legend is of interest 
to you , I'll post  code snippets

Cheers, Martin


On Friday 12 December 2003 05:06, Emilio Mayorga wrote:
> Thanks, Steve. That's great to hear.
>
> I don't have my trusty DHTML book with me, so I can't research this too
> much right now. I'll do it this weekend (maybe). I want to see if
> there's a way to create a new DOM node where the HTML can be brought in
> from a URL (in this case, the dynamically generated CGI statement with
> mode=legend), then inserted into a DIV via innerHTML, or something like
> that.
>
> Meanwhile, I experimented with an IFRAME. It's not ideal (iframes seem
> inelegant, in principle!), but I got it to work. If you're curious, my
> test site is here:
> http://basin.ocean.washington.edu/mapserv/mapache/eng/main.html
> It's a very rudimentary site at this point. I don't know how to use the
> CBE library yet, unfortunately. I'd like to.
>
> BTW, I took a quick look at cbs.sportsline.com. Without trying to
> understand everything, it looks like it uses an IFRAME element, too.
>
> Here are the relevant bits that I implemented:
> ** In the HTML page:
> <iframe id="legendiframe" src="blank.html" width="150" height="200"
> scrolling="auto" frameborder="0">
> [text for browsers that don't support iframes.]
> </iframe>
>
> ** Then I have this javascript code:
> function postdraw() {
>    // update the legend
>    var getlegendiframe = document.getElementById('legendiframe');
>    getlegendiframe.src = MapServer + "?map=" + mapfile +
> "&mode=legend&mapext=0+0+" + (ms.extent[2] - ms.extent[0]) + "+" +
> (ms.extent[3] - ms.extent[1]) + "&mapsize=" + ms.width + "+" + ms.height;
> }
>
> I hope this is helpful to you. I might call it quits and settle with
> this kludge, but I'd love to hear what you come up with.
>
> -Emilio Mayorga
> Central American Ecology & Environment
> garrobo.org
>
> Steve Lime wrote:
> > Hi Emilio: I'm working on something similar. Just haven't had time to
> > make progress. Basically I was thinking of a dLegend object. Like the
> > dBox interface I would use an anchor image to place a DTHML layer
> > containing (with scrollbars) on a page. The layer would contain exactly
> > what you mention below, an HTML legend. There's a good example of such a
> > control at cbs.sportsline.com, the scores at a glance tool. I want to
> > implement it using the same library (CBE) as dBox uses.
> >
> > Bottom line, I have no solution for you, only an idea. If you make
> > progress please let me know.
> >
> > Steve
> >
> > Stephen Lime
> > Data & Applications Manager
> >
> > Minnesota DNR
> > 500 Lafayette Road
> > St. Paul, MN 55155
> > 651-297-2937
> >
> >>>>Emilio Mayorga <emiliom at u.washington.edu> 12/11/2003 2:49:02 PM
> >
> > I've implemented Steve Lime's DHTML interface with dBox (javascript
> > rubber band). It's working great (thanks!).
> >
> > Now I'd like to add an HTML legend. I can get my map file to generate
> > the HTML for the legend using a stand-alone CGI line; that seems to
> > work
> > fine. But I can't figure out how to use that line to insert the HTML
> > into my web page.
> >
> > I know some DHTML/DOM/javascript. What I'd like to know is how to take
> > the result of something like:
> > http://mysite/cgi-bin/mapserv?map=/var/www/html/mymapfile.map&mode=legend
> > and insert it into a web page, without using Frames.
> >
> > Thanks for your help. Cheers,
> >
> > -Emilio Mayorga
> >
> >
> > _______________________________________________
> > Mapserver-users mailing list
> > Mapserver-users at lists.gis.umn.edu
> > http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
>
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users

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






More information about the mapserver-users mailing list