<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<html>
<head>
<title>
ka-Map Overview
</title>
<link rel ="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script>
function asd() {
parent.document.title="wmsLayer.js Overview";
}
</script>
</head>
<body bgcolor="white" onload="asd();">
<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
<tr align="center" valign="top">
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a> </td>
<td bgcolor="#FFFFFF" class="NavBarCell1Rev"> <font class="NavBarFont1Rev"><b>File</b></font> </td>
<td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font> </td>
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a> </td>
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a> </td>
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a> </td>
</tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top">
<em>
<b>ka-Map</b></em>
</td>
</tr>
<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
PREV
NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
<a href="index.html" target="_top"><b>FRAMES</b></a>
<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
<script>
<!--
if(window==top) {
document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
}
//-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->
<hr>
<center>
<h2>wmsLayer.js</h2>
</center>
<h4>Summary</h4>
<p>
No overview generated for 'wmsLayer.js'<BR/><BR/>
</p>
<hr>
<table border="1" cellpadding="3" cellspacing="0" width="100%">
<tr bgcolor="#CCCCFF" class="TableHeadingColor">
<td colspan=2><font size="+2">
<b>Class Summary</b>
</font></td>
</tr>
<tr bgcolor="white" class="TableRowColor">
<td width="15%"><b><a href="_wmsLayer.html">_wmsLayer</a></b></td>
<td> </td>
</tr>
</table>
<hr/>
<!-- ========== METHOD SUMMARY =========== -->
<!-- ========== END METHOD SUMMARY =========== -->
<pre class="sourceview"><span class="comment">/**********************************************************************
*
* $Id: overview-summary-wmsLayer.js.html,v 1.1 2006/03/15 15:56:59 pspencer Exp $
*
* purpose: an alternate layer type that can render directly from a
* WMS rather than from the tile cache
*
* author: Paul Spencer (pspencer<span class="attrib">@dmsolutions</span>.ca)
*
* TODO:
* - implementation is very preliminary, missing SRS at least
* - layers added don't show up in the legend ...
*
**********************************************************************
*
* Copyright (c) 2005, DM Solutions Group Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
**********************************************************************/</span>
<span class="comment">/******************************************************************************
* _wmsLayer - a special type of layer object that represents a WMS layer. It
* is special because this layer renders directly from the WMS
* server rather than through a tile caching service.
*
* To use _wmsLayer:
*
* 1) add a script tag to your page:
*
* <script type="text/javascript" src="wmsLayer.js"></script>
*
* 2) create a new instance of _wmsLayer
*
* var l = new _wmsLayer( szName, bVisible, opacity, imageformat, bQueryable,
* server, version, layers, srs);
*
* 3) add it to the map
*
* myKaMap.addMapLayer( l );
*
* For instance, assuming you have a form to input the parameters required:
*
* function addWMSLayer()
* {
* var f = document.forms.wms;
* var szName = f.wmsName.value;
* var bVisible = true;
* var opacity = 100;
* var imageformat = "image/png";
* var bQueryable = true;
* var server = f.wmsServer.value;
* var version = "1.1.1";
* var layers = f.wmsLayers.value;
* var srs = f.wmsSRS.value;
* var l = new _wmsLayer( szName, bVisible, opacity, imageformat, bQueryable,
* server, version, layers, srs);
* myKaMap.addMapLayer( l );
* }
*
*****************************************************************************/</span>
<span class="reserved">function</span> _wmsLayer( szName, bVisible, opacity, imageformat, bQueryable,
server, version, layers, srs) {
_layer.apply(<span class="reserved">this</span>,[szName,bVisible,opacity,imageformat,bQueryable]);
<span class="reserved">this</span>.server = server;
<span class="reserved">this</span>.version = (version && version != <span class="literal">''</span>) ? version : <span class="literal">'1.1.1'</span>;
<span class="reserved">this</span>.layers = layers;
<span class="reserved">this</span>.srs = srs;
<span class="reserved">this</span>.bWidthHeight = false; <span class="comment">//track adding width/height</span>
<span class="reserved">this</span>.baseURL = <span class="reserved">this</span>.server;
<span class="comment">/*
* make sure the server url is terminated with a ? or not a & so we can
* append the rest of the request without having to worry about a
* correctly formatted url
*/</span>
<span class="reserved">if</span> (<span class="reserved">this</span>.baseURL.indexOf(<span class="literal">'?'</span>) == -1) {
<span class="reserved">this</span>.baseURL = <span class="reserved">this</span>.baseURL + <span class="literal">'?'</span>;
} <span class="reserved">else</span> {
<span class="reserved">if</span> (<span class="reserved">this</span>.baseURL.charAt( <span class="reserved">this</span>.baseURL.length - 1 ) == <span class="literal">'&'</span>)
<span class="reserved">this</span>.baseURL = <span class="reserved">this</span>.baseURL.slice( 0, -1 );
}
<span class="comment">/*
* required components of WMS 1.1.1 are:
* VERSION set to version or 1.1.1 if version is empty
* REQUEST - set to GetMap if not in the server URL
* LAYERS - set to layers if not in the server URL
* STYLES - not supported in this code, add to server URL yourself
* SRS - set to srs if not in the server URL
* BBOX - set dynamically by setTile()
* WIDTH - set to tile height if not in the server URL
* HEIGHT - set to tile width if not in the server URL
* FORMAT - set to imageformat if not in the server URL
*
* Optional components are:
*
* TRANSPARENT - set to ON if not in the server URL
* BGCOLOR - do not add this, it will interfer with transparency
* EXCEPTIONS - set to in image if not in the server URL
* TIME - not supported in this code, add to server URL yourself
* ELEVATION - not supported in this code, add to server URL yourself
* SLD (SLD only) - not supported in this code, add to server URL yourself
* WFS (SLD only) - not supported in this code, add to server URL yourself
*/</span>
<span class="reserved">this</span>.addRequestParameter( <span class="literal">'service'</span>, <span class="literal">"&service=WMS"</span> );
<span class="reserved">this</span>.addRequestParameter( <span class="literal">'request'</span>, <span class="literal">"&request=GetMap"</span> );
<span class="reserved">this</span>.addRequestParameter( <span class="literal">'version'</span>, <span class="literal">"&version="</span>+<span class="reserved">this</span>.version );
<span class="reserved">this</span>.addRequestParameter( <span class="literal">'layers'</span>, <span class="literal">"&layers="</span> + escape(<span class="reserved">this</span>.layers) );
<span class="reserved">this</span>.addRequestParameter( <span class="literal">'srs'</span>, <span class="literal">"&srs="</span> + <span class="reserved">this</span>.srs );
<span class="reserved">this</span>.addRequestParameter( <span class="literal">'styles'</span>, <span class="literal">"&styles="</span> );
<span class="reserved">this</span>.addRequestParameter( <span class="literal">'format'</span>, <span class="literal">"&format="</span> + <span class="reserved">this</span>.imageformat );
<span class="reserved">this</span>.addRequestParameter( <span class="literal">'transparent'</span>, <span class="literal">'&transparent=true'</span> );
<span class="reserved">this</span>.addRequestParameter( <span class="literal">'exceptions'</span>, <span class="literal">'&exceptions=application/vnd.ogc.se-inimage'</span> );
<span class="reserved">for</span> (var p in _layer.<span class="reserved">prototype</span>) {
<span class="reserved">if</span> (!_wmsLayer.<span class="reserved">prototype</span>[p])
_wmsLayer.<span class="reserved">prototype</span>[p]= _layer.<span class="reserved">prototype</span>[p];
}
};
<span class="comment">/**
* wmsLayer.addRequestParameter( name, parameter )
*
* add a parameter to the baseURL safely by checking to see if the parameter
* exists already. This is an internal function not intended to be used
* by other code.
*/</span>
_wmsLayer.<span class="reserved">prototype</span>.addRequestParameter = <span class="reserved">function</span>( name, parameter ) {
<span class="reserved">if</span> (<span class="reserved">this</span>.baseURL.indexOf( name ) == -1) {
<span class="reserved">this</span>.baseURL = <span class="reserved">this</span>.baseURL + parameter;
}
};
_wmsLayer.<span class="reserved">prototype</span>.setTile = <span class="reserved">function</span>(img) {
var url = <span class="reserved">this</span>.baseURL;
var km = <span class="reserved">this</span>._map.kaMap;
<span class="comment">//only do this once - we don't have _map when the layer is initialized</span>
<span class="reserved">if</span> (!<span class="reserved">this</span>.bWidthHeight) {
<span class="reserved">this</span>.addRequestParameter( <span class="literal">'width'</span>, <span class="literal">'&width='</span>+km.tileWidth );
<span class="reserved">this</span>.addRequestParameter( <span class="literal">'height'</span>, <span class="literal">'&height='</span>+km.tileHeight );
}
var l = km.cellSize * (safeParseInt(img.style.left) + km.xOrigin);
var t = -1*km.cellSize * (safeParseInt(img.style.top) + km.yOrigin);
var r = l + km.cellSize * km.tileWidth;
var b = t - km.cellSize * km.tileHeight;
url = url + <span class="literal">"&BBOX="</span> + l + <span class="literal">","</span> + b + <span class="literal">","</span> + r + <span class="literal">","</span> + t;
<span class="reserved">if</span> (img.src != url) {
img.style.visibility = <span class="literal">'hidden'</span>;
img.src = url;
}
};</pre>
<hr>
<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
<tr align="center" valign="top">
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a> </td>
<td bgcolor="#FFFFFF" class="NavBarCell1Rev"> <font class="NavBarFont1Rev"><b>File</b></font> </td>
<td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font> </td>
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a> </td>
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a> </td>
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a> </td>
</tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top"><em>
<b>ka-Map</b></em>
</td>
</tr>
<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
PREV
NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
<a href="index.html" target="_top"><b>FRAMES</b></a>
<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
<script>
<!--
if(window==top) {
document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
}
//-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->
<hr>
<font size="-1">
</font>
<div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Wed Mar 15 10:50:59 2006</div>
</body>
</html>