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.
I was wondering if anyone can point out the problem in th开发者_运维技巧e 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.
OpenLayers code:
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:
[mapnik24]
type=Mapnik
mapfile=/somedit/map24.xml
bbox=-2.0,50.0,2.0,54.0
levels=20
srs=EPSG:4326
projection=+proj=latlong +datum=WGS84
-- Thanks, A
The OpenLayers.Bounds constructor parameters are in the order left, bottom, right top. Taking the bounds that you're using change your JavaScript to be:
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?
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. 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. So the bbox should be 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?
精彩评论