简体   繁体   English

OpenLayers Map BoundingBox计算

[英]OpenLayers Map BoundingBox calculation

I'm using the GeoServer to hold some maps, and just a simple OpenLayers app to load and show the data (for now). 我正在使用GeoServer来保存一些地图,并且仅使用一个简单的OpenLayers应用程序来加载和显示数据(目前)。

I'm successfully loading the demo data (which is in WGS84), but when it comes to my data (which is in Balkans Zone 7, EPSG:31277), when I look at the request, it seems like the BBOX is completely out of order. 我已经成功加载了演示数据(位于WGS84中),但是当涉及到我的数据(位于Balkans Zone 7中,EPSG:31277)时,当我查看请求时,似乎BBOX完全耗尽了的顺序。

I checked the BBOX from the GeoServer preview page (which is made with openLayers) and it looks like this, and works: 我从GeoServer预览页面(由openLayers创建)中检查了BBOX,它看起来像这样,并且可以正常工作:

http://127.0.0.1:2113/geoserver/GISHome/wms?LAYERS=GISHome%3ANis11Katastar&STYLES=&FORMAT=image%2Fjpeg&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&SRS=EPSG%3A31277&BBOX=7572000,4796000,7574000,4798000&WIDTH=512&HEIGHT=512

The only thing that's different with my request is the BBOX. 我的要求唯一不同的是BBOX。 When copying the BBOX into my request, it works. 将BBOX复制到我的请求中时,它可以工作。

http://127.0.0.1:2113/geoserver/wms?LAYERS=Nis11Katastar&FORMAT=image%2Fpng&WIDTH=256&HEIGHT=256&PROJECTION=EPSG%3A31277&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&SRS=EPSG%3A4326&BBOX=-180,-90,0,90

In the GeoServer source, the bounds are somehow calculated and hardcoded. 在GeoServer源代码中,以某种方式计算并硬编码了边界。 The question is, how? 问题是,如何? Is there a way not to hardcode them? 有没有办法不对它们进行硬编码? How should I calculate them. 我应该如何计算它们。 I've tried adding bounds, maxExtent, resolution, I'm obviously missing something more than that here. 我尝试添加界限,maxExtent,分辨率,但我显然比这里遗漏了更多东西。 The GeoServer works fine, I'm using the layers from QuantumGIS. GeoServer工作正常,我正在使用QuantumGIS中的图层。

Ext.onReady(function() {
    var map = new OpenLayers.Map();
    var layer = new OpenLayers.Layer.WMS(
        "Global Imagery",
        "http://127.0.0.1:2113/geoserver/wms",
       {  
        LAYERS:'Nis11Katastar',
        format: 'image/png',
        width:600,
        height:400,
        projection: new OpenLayers.Projection("EPSG:31277"),
        }
    );

Thankyou. 谢谢。

Oh, yes, I'm using GeoExt, but that doesn't change much. 哦,是的,我正在使用GeoExt,但这并没有太大变化。

It seems solved. 好像解决了 I was setting the right properties, but to the WMS layer object, not to the map object. 我在设置正确的属性,但设置了WMS图层对象,而不是地图对象。 As for the bounds question, I'm just copying the bounds from the geoserver control panel. 至于边界问题,我只是从geoserver控制面板复制边界。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM