我创建了一个简单的html来测试我制作的一些地图图块。问题是我让他们使用TMS投影,但我使用了一个OSM示例,所以我的所有图块都是颠倒显示的。我尝试切换到TMS,但经过几十次尝试失败后,我似乎错过了一些东西,有人可以帮忙修复代码吗?
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css" />
<script src="OpenLayers.js"></script>
<script src="OpenStreetMap.js"></script>
<script type="text/javascript">
var map, layer;
//Initialise the 'map' object
function init() {
map = new OpenLayers.Map ("map", {
controls:[
new OpenLayers.Control.Navigation(),
new OpenLayers.Control.PanZoomBar(),
new OpenLayers.Control.Permalink(),
new OpenLayers.Control.ScaleLine({geodesic: true}),
new OpenLayers.Control.Permalink('permalink'),
new OpenLayers.Control.MousePosition(),
new OpenLayers.Control.Attribution()],
maxExtent: new OpenLayers.Bounds( 0.0, -10000.0, 10000.0, 0.0),
maxResolution: 64.000000,
numZoomLevels: 7,
units: 'm',
projection: new OpenLayers.Projection("EPSG:900913"),
displayProjection: new OpenLayers.Projection("EPSG:4326")
} );
// Add Base map.
layer = new OpenLayers.Layer.OSM("Base Map", "tiles/base/${z}/${x}/${y}.jpg", {numZoomLevels: 7, alpha: false, isBaseLayer: true});
map.addLayer(layer);
// Add Layers.
layer = new OpenLayers.Layer.OSM("Terrain", "tiles/terrain/${z}/${x}/${y}.png", {numZoomLevels: 7, alpha: false, isBaseLayer: false});
map.addLayer(layer);
layer = new OpenLayers.Layer.OSM("Lables", "tiles/lables/${z}/${x}/${y}.png", {numZoomLevels: 7, alpha: false, isBaseLayer: false});
map.addLayer(layer);
var switcherControl = new OpenLayers.Control.LayerSwitcher();
map.addControl(switcherControl);
switcherControl.maximizeControl();
if( ! map.getCenter() ){
var lonLat = new OpenLayers.LonLat(10, 10).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject());
map.setCenter (lonLat, 5);
}
}
</script>
</head>
<body onload="init();">
<div style="width:100%; height:100%" id="map"></div>
</body>
</html>
基本上我需要的是一个基本地图图层(jpg)和几个可选图层(png具有透明度)全部使用TMS,256x256,7个缩放级别并位于'tiles / layername /...'