diff --git a/examples/kamap.html b/examples/kamap.html
index 64e886012e..80a641766e 100644
--- a/examples/kamap.html
+++ b/examples/kamap.html
@@ -16,10 +16,15 @@
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' }, new OpenLayers.LonLat(0,0));
+ "http://freemap.in/~crschmidt/ka-map/ka-map-0.2-20060208/htdocs/tile.php?" , { map: 'gmap', g: 'roads' }, 'degrees', 72 );
+ var jpl_wms = new OpenLayers.Layer.WMS( "NASA Global Mosaic",
+ "http://wms.jpl.nasa.gov/wms.cgi",
+ {layers: "modis,global_mosaic"});
- map.addLayers([ol_wms, ka_wms]);
+
+
+ map.addLayers([jpl_wms, ka_wms]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.setCenter(new OpenLayers.LonLat(0, 0), 0);
}
diff --git a/examples/tiger.html b/examples/tiger.html
index 7b59e393d5..e965786cec 100644
--- a/examples/tiger.html
+++ b/examples/tiger.html
@@ -13,13 +13,13 @@
function init(){
var map = new OpenLayers.Map('map', {'maxResolution': 1.2/4, controls:[]});
- var ka_wms = new OpenLayers.Layer.KaMap( "KaMap", "http://maps.dmsolutions.ca/demo/us_streets/tile.php", {map:'tiger04', g:'__base__'}, new OpenLayers.LonLat(0,0));
+ var ka_wms = new OpenLayers.Layer.KaMap( "KaMap", "http://maps.dmsolutions.ca/demo/us_streets/tile.php", {map:'tiger04', g:'__base__'});
ka_wms.setTileSize(new OpenLayers.Size(300,300));
map.addLayers([ka_wms]); // , ka_wms, kamap_wms]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.MouseToolbar());
map.addControl(new OpenLayers.Control.PanZoomBar());
- map.setCenter(new OpenLayers.LonLat(-70, 30), 2);
+ map.setCenter(new OpenLayers.LonLat(-96, 35), 2);
}
// -->
diff --git a/lib/OpenLayers/Layer/KaMap.js b/lib/OpenLayers/Layer/KaMap.js
index e4f4145410..687be2ee3d 100644
--- a/lib/OpenLayers/Layer/KaMap.js
+++ b/lib/OpenLayers/Layer/KaMap.js
@@ -6,10 +6,16 @@
* @class
*/
OpenLayers.Layer.KaMap = Class.create();
+
+
OpenLayers.Layer.KaMap.prototype =
Object.extend( new OpenLayers.Layer.Grid(), {
- metaTileHeight: 6,
- metaTileWidth: 6,
+
+ units: 'degrees',
+ scales: {inches: 1, feet: 12, miles: 63360.0, meters: 39.3701, kilometers: 39370.1, degrees: 4374754},
+
+
+ resolution: 72,
DEFAULT_PARAMS: {
i: 'jpeg',
@@ -18,9 +24,10 @@ OpenLayers.Layer.KaMap.prototype =
// 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, origin) {
- this.kaOrigin = origin;
+ initialize: function(name, url, params, units, resolution) {
var newArguments = new Array();
+ if (units) this.units = units;
+ if (resolution) this.resolution = resolution;
newArguments.push(name, url, params);
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
this.params = (params ? params : {});
@@ -33,13 +40,13 @@ OpenLayers.Layer.KaMap.prototype =
},
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 + this.kaOrigin.lon) / cellSize.w) * this.tileSize.w);
- var pY = -Math.floor(((bounds.top+this.kaOrigin.lat) / cellSize.h) * this.tileSize.h);
+ var maxRes = this.map.maxResolution;
+ var mapRes = this.map.getResolution();
+ var scale = (((this.tileSize.w * this.map.maxResolution * this.resolution) * (this.scales[this.units])) / this.tileSize.w) / Math.pow(2, zoom);
+
+ var cellSize = new OpenLayers.Size(mapRes*this.tileSize.w, mapRes*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,