OpenLayers.Layer.KaMap, for displaying KaMap-tiles in OpenLayers. Currently specific to the example -- needs work on determining 'scale' from resolution. possibly just simple math. I'm not sure yet.

git-svn-id: http://svn.openlayers.org/trunk/openlayers@665 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2006-06-21 21:49:31 +00:00
parent bf6ad055df
commit 98ed96e4ec
3 changed files with 86 additions and 0 deletions

33
examples/kamap.html Normal file
View File

@@ -0,0 +1,33 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#map {
width: 800px;
height: 475px;
border: 1px solid black;
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
<!--
function init(){
var map = new OpenLayers.Map('map', {'maxResolution': 1.40625/4});
var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'} );
var ka_wms = new OpenLayers.Layer.KaMap( "KaMap",
"http://www.h2guide.com/my-ka-map/h2tile.php?" , { map: 'h2guide', g: 'background' });
map.addLayers([ol_wms, ka_wms]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.setCenter(new OpenLayers.LonLat(0, 0), 0);
}
// -->
</script>
</head>
<body onload="init()">
<h1>OpenLayers Example</h1>
<div id="map"></div>
</body>
</html>

View File

@@ -64,6 +64,7 @@ if (typeof(_OPENLAYERS_SFL_) == "undefined") {
// "OpenLayers/Layer/VirtualEarth.js",
// "OpenLayers/Layer/Yahoo.js",
"OpenLayers/Layer/Grid.js",
"OpenLayers/Layer/KaMap.js",
"OpenLayers/Layer/Markers.js",
"OpenLayers/Layer/Text.js",
"OpenLayers/Layer/WMS.js",

View File

@@ -0,0 +1,52 @@
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
// @require: OpenLayers/Layer/Grid.js
/**
* @class
*/
OpenLayers.Layer.KaMap = Class.create();
OpenLayers.Layer.KaMap.prototype =
Object.extend( new OpenLayers.Layer.Grid(), {
metaTileHeight: 6,
metaTileWidth: 6,
DEFAULT_PARAMS: {
i: 'jpeg',
map: '',
},
// this.cellSize = newScale/(oMap.resolution * inchesPerUnit[oMap.units]);
// kaMap.prototype.geoToPix = function( gX, gY ) { var pX = gX / this.cellSize; var pY = -1 * gY / this.cellSize; }
initialize: function(name, url, params) {
var newArguments = new Array();
newArguments.push(name, url, params);
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
this.params = (params ? params : {});
if (arguments.length > 0 && params) {
OpenLayers.Util.applyDefaults(
this.params,
this.DEFAULT_PARAMS
);
}
},
addTile:function(bounds,position) {
var zoom = this.map.getZoom();
var resolution = this.map.getResolution();
var scale = 128000000 / Math.pow(2, zoom);
// 1280000 is an empirical value for a specific tile server, not yet figured out the right way to do this in general.
// This will probably be based on map.maxResolution.
var cellSize = new OpenLayers.Size(resolution*this.tileSize.w, resolution*this.tileSize.h);
var pX = Math.floor(bounds.left / cellSize.w) * this.tileSize.w;
var pY = -Math.floor(bounds.top / cellSize.h) * this.tileSize.h;
var url = this.getFullRequestString(
{ t: pY,
l: pX,
s: scale,
});
return new OpenLayers.Tile.Image(this, position, bounds,
url, this.tileSize);
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Layer.KaMap"
});