[英]Openlayers + Mapnik + Tilecache configuration problem
I am trying to setup Mapnik + tilecache but can't see any tiles in the browser when I set bbox parameters in both Tilecache.cfg and Openlayers but when I don't specify the bbox everything works fine and I can see actual map tiles. 我试图设置Mapnik + tilecache,但是当我在Tilecache.cfg和Openlayers中设置bbox参数时,在浏览器中看不到任何图块但是当我没有指定bbox时,一切正常,我可以看到实际的地图图块。
I was wondering if anyone can point out the problem in the code. 我想知道是否有人可以在代码中指出问题。 I think I have tried everything ( in my limited capability) and not really understanding why would it not work.
我想我已经尝试了所有东西(以我有限的能力)而不是真正理解为什么它不起作用。 By the way all map layers ( for mapnik styling) are sourced from a PostGIS database and have different projections and transformed on the fly by Mapnik.
顺便说一句,所有地图图层(用于mapnik样式)都来自PostGIS数据库,并具有不同的投影,并由Mapnik动态转换。
OpenLayers code: OpenLayers代码:
var map, layer;
function init(){
var map, layer;
var options = {
numZoomLevels:20,
maxResolution: 360/512,
projection: "EPSG:4326",
maxExtent: new OpenLayers.Bounds(-2.0,50.0,2.0,54.0)
//not working when uncommented
};
map = new OpenLayers.Map( 'map', options);
layer = new OpenLayers.Layer.WMS( "Map24","tilecache.py?",
{
layers:'mapnik24',
format: 'image/png',
srs: 'EPSG:4326'
} );
map.addLayer(layer);
map.addControl( new OpenLayers.Control.PanZoomBar());
map.addControl( new OpenLayers.Control.MousePosition());
map.addControl( new OpenLayers.Control.LayerSwitcher());
map.addControl( new OpenLayers.Control.Permalink("permalink"));
if (!map.getCenter()) map.zoomToMaxExtent();
}
Tilecache.cfg: Tilecache.cfg:
[mapnik24] [mapnik24]
type=Mapnik 键入= Mapnik的
mapfile=/somedit/map24.xml 映射文件= / somedit / map24.xml
bbox=-2.0,50.0,2.0,54.0 BBOX = -2.0,50.0,2.0,54.0
levels=20 水平= 20
srs=EPSG:4326 SRS = EPSG:4326
projection=+proj=latlong +datum=WGS84 projection = + proj = latlong + datum = WGS84
-- Thanks, A - 谢谢
The OpenLayers.Bounds constructor parameters are in the order left, bottom, right top. OpenLayers.Bounds构造函数参数的顺序为left,bottom,right top。 Taking the bounds that you're using change your JavaScript to be:
采用您正在使用的界限将您的JavaScript更改为:
var options = {
numZoomLevels:20,
maxResolution: 360/512,
projection: "EPSG:4326",
maxExtent: new OpenLayers.Bounds(50.0,-2.0,54.0,2.0)
//not working when uncommented
};
Have you tried plugging in the parameters for tilecache.py directly to see if a tile is generated? 您是否尝试直接插入tilecache.py的参数以查看是否生成了磁贴?
Looking at your code I think you are asking for the region bounded by 50 and 54 degrees east, and 2 degrees north and south. 看看你的代码,我想你要的是东边50和54度,北纬2度的区域。 Is this correct?
这个对吗?
If it is, then I think your bounds are the wrong way around. 如果是,那么我认为你的界限是错误的。 -2 degrees (south) should be at the bottom, and 2 degrees (north) should be at the top.
-2度(南)应位于底部,2度(北)应位于顶部。 So the bbox should be
2.0,50.0,-2.0,54.0
. 所以bbox应该是
2.0,50.0,-2.0,54.0
。
Also, looking at that region in OpenStreetMap it looks like there's not much there, is that really what you intend? 另外,在OpenStreetMap中查看该区域看起来并不多,那真的是你想要的吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.