[OpenLayers-Users] Own map layer in different projection
dalori
shoppen at bananenhand.de
Wed Jun 27 02:18:34 PDT 2012
Yes I have. :-)
<!DOCTYPE HTML>
<html>
<head>
<title>Rectangular tiles</title>
<style type="text/css">
html, body, #map {
width: 100%;
height: 100%;
margin: 0;
}
</style>
<script src="http://www.openlayers.org/api/OpenLayers.js"></script>
<script>
function get_my_url(bounds) {
var res = this.map.getResolution();
var x = Math.round((bounds.left - this.maxExtent.left) / (res *
this.tileSize.w));
var y = Math.round((this.maxExtent.top - bounds.top) / (res *
this.tileSize.h));
var z = this.map.getZoom();
// tiles are named like 0001 instead of simply 1
x = "000" + x;
x = x.substring(4, 0);
y = "000" + y;
y = y.substring(4, 0);
var path = z + "/" + x + "/tile_" + y + "." + this.type;
var url = this.url;
if( url instanceof Array) {
url = this.selectUrl(path, url);
}
return url + path;
}
var map, point, markers;
function init() {
point = new OpenLayers.LonLat(54.167258, -131.662903);
map = new OpenLayers.Map("map", {
tileSize : new OpenLayers.Size(512, 512)
});
map.addLayer(new OpenLayers.Layer.TMS("Name",
"http://www.bananenhand.de/background/level", {
'type' : 'jpg',
'getURL' : get_my_url
}));
map.setCenter(point, 2);
markers = new OpenLayers.Layer.Markers("Markers");
map.addLayer(markers);
markers.addMarker(new OpenLayers.Marker(point));
}
</script>
</head>
<body onload="init();">
<div id="map"></div>
</body>
</html>
--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Own-map-layer-in-different-projection-tp4984150p4984159.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20120627/1c25cb0b/attachment-0001.html>
More information about the Users
mailing list