AW: [mapserver-users] Possible to use JavaScript code in a MapServertemplate?

Arnd Wippermann arnd.wippermann at web.de
Mon Oct 31 12:11:17 EDT 2011


Hi,
 
MapServer 6 comes with "Built-in OpenLayers map viewer", template with use
of OpenLayers javascript library.
 
see http://mapserver.org/development/rfc/ms-rfc-63.html
 
 
an example, how I use javascript in templates:
 
<!-- Mapserver Template (Body Template) -->
<!-- styles are defined in Header Template -->
 
<script>
 
var idx = parseInt("[lrn]")%2;
var myClass = "tdBody" + idx;
 
if("[version]".search(/version 5.6.1/)!=-1)
    var imgLeg =
"...?map=mapfile_561.map&SERVICE=WMS&VERSION=1.1.1&REQUEST=getlegendgraphic&
LAYER=[cl]&FORMAT=image/png&STYLES=";
else if("[version]".search(/version 6./)!=-1)
    var imgLeg =
"...?map=mapfile_6.map&SERVICE=WMS&VERSION=1.1.1&REQUEST=getlegendgraphic&LA
YER=[cl]&FORMAT=image/png&STYLES=";
else
    var imgLeg =
"...?map=mapfile_49.map&SERVICE=WMS&VERSION=1.1.1&REQUEST=getlegendgraphic&L
AYER=[cl]&FORMAT=image/png&STYLES=";
 
document.write("<tr class='tblBody'>");
document.write("    <td class='" + myClass + "'><img src='" + imgLeg +
"'></td>");
document.write("    <td class='" + myClass + "'>[NAME_LOCAL]</td>");
document.write("    <td class='" + myClass + "'>[NAME_FAO]</td>");
document.write("    <td class='" + myClass + "'>[UNREGION2]</td>");
document.write("</tr>");
 
</script>

Arnd

  _____  

Von: mapserver-users-bounces at lists.osgeo.org
[mailto:mapserver-users-bounces at lists.osgeo.org] Im Auftrag von Bistrais,
Bob
Gesendet: Montag, 31. Oktober 2011 16:11
An: mapserver-users at lists.osgeo.org
Betreff: [mapserver-users] Possible to use JavaScript code in a
MapServertemplate?



Is it possible to write and execute JavaScript within a MapServer template?
What I'd like to do, when a ProcessTemplate is called for a certain layer, I
would like to check item values.  If item values equal a certain value,
write something to the output.  It would seem possible since a template is
an HTML file, but I'm just not sure how to do it, or if it's possible. 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-users/attachments/20111031/5ef1366e/attachment-0001.html


More information about the mapserver-users mailing list