Permalink
Switch branches/tags
Find file
Fetching contributors…
Cannot retrieve contributors at this time
71 lines (60 sloc) 3.13 KB
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- Modified from openlayers.html file generated by gdal2tiles.py.
<a href="http://www.maptiler.org/">MapTiler</a>/<a href="http://www.klokan.cz/projects/gdal2tiles/">GDAL2Tiles</a>, Copyright &copy; 2008 <a href="http://www.klokan.cz/">Klokan Petr Pridal</a>, <a href="http://www.gdal.org/">GDAL</a> &amp; <a href="http://www.osgeo.org/">OSGeo</a> <a href="http://code.google.com/soc/">GSoC</a>-->
<html xmlns="http://www.w3.org/1999/xhtml"
<head>
<title>OpenLayer TMS Layer</title>
<meta http-equiv='imagetoolbar' content='no'/>
<link rel="stylesheet" href="qgis.css" type="text/css">
<style type="text/css">
html,body { height: 100%; width: 100%; }
</style>
<script src="http://www.openlayers.org/api/2.7/OpenLayers.js" type="text/javascript"></script>
<script type="text/javascript">
var map;
var mapBounds = new OpenLayers.Bounds( 15.9362103992, -34.9154044606, 33.5135016314, -21.9620062721);
// set to min / max zoom levels for which there are tiles
var mapMinZoom = 1;
var mapMaxZoom = 10;
// avoid pink tiles
OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;
OpenLayers.Util.onImageLoadErrorColor = "transparent";
function init(){
var options = {
controls: [],
projection: new OpenLayers.Projection("EPSG:900913"),
displayProjection: new OpenLayers.Projection("EPSG:4326"),
units: "m",
maxResolution: 156543.0339,
//set to maximum extent of TMS (use gdalinfo)
maxExtent: new OpenLayers.Bounds(-20037508, -20037508, 20037508, 20037508.34)
};
map = new OpenLayers.Map('map', options);
// create TMS Overlay layer
var tmsoverlay = new OpenLayers.Layer.TMS( "TMS Overlay", "",
{ // url: '', serviceVersion: '.', layername: '.',
type: 'png', getURL: overlay_getTileURL, alpha: true
//isBaseLayer: false
});
map.addLayer(tmsoverlay);
map.zoomToExtent( mapBounds.transform(map.displayProjection, map.projection ) );
}
function overlay_getTileURL(bounds) {
var res = this.map.getResolution();
var x = Math.round((bounds.left - this.maxExtent.left) / (res * this.tileSize.w));
var y = Math.round((bounds.bottom - this.tileOrigin.lat) / (res * this.tileSize.h));
var z = this.map.getZoom();
if (mapBounds.intersectsBounds( bounds ) && z >= mapMinZoom && z <= mapMaxZoom ) {
// set to base url of tiles
return "/home/rudi/personal/GIS/trash/trshmap/" + z + "/" + x + "/" + y + "." + this.type;
} else {
return "http://www.maptiler.org/img/none.png";
}
}
</script>
</head>
<body onload="init()">
<div id="map"></div>
<script type="text/javascript" >resize()</script>
</body>
</html>