Openlayers +马普尼克+ Tilecache配置问题

发布于 2024-08-12 07:25:24 字数 1627 浏览 4 评论 0原文

我正在尝试设置 Mapnik +tilecache,但当我在 Tilecache.cfg 和 Openlayers 中设置 bbox 参数时,在浏览器中看不到任何图块,但当我不指定 bbox 时,一切正常,我可以看到实际的地图图块。

我想知道是否有人可以指出代码中的问题。我想我已经尝试了一切(以我有限的能力),但并没有真正理解为什么它不起作用。顺便说一句,所有地图图层(用于 Mapnik 样式)均源自 PostGIS 数据库,并具有不同的投影并由 Mapnik 动态转换。

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:

[mapnik24]

类型=Mapnik

mapfile=/someedit/map24.xml

bbox=-2.0,50.0,2.0,54.0

级别=20

srs=EPSG:4326

投影=+proj=latlong +datum=WGS84

- - 谢谢, 一个

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 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.

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

明月松间行 2024-08-19 07:25:24

OpenLayers.Bounds 构造函数参数的顺序是左、下、右上。将您正在使用的边界更改为:

            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
            };

您是否尝试过直接插入tilecache.py的参数来查看是否生成了图块?

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?

冷心人i 2024-08-19 07:25:24

看看你的代码,我认为你要求的区域是东经 50 度和 54 度,北纬 2 度和南纬 2 度。这是正确的吗?

如果是的话,那么我认为你的界限是错误的。 -2 度(南)应位于底部,2 度(北)应位于顶部。所以bbox应该是2.0,50.0,-2.0,54.0

另外,查看 OpenStreetMap 看起来没有太多内容,这真的是你想要的吗?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文