首页 文章

GeoServer WMS不会加载OpenLayers

提问于
浏览
2

我知道网上有很多关于此的帖子,但我无法在GeoServer中获取我的WMS图层以加载OpenLayers . OpenLayers将图层添加到“图层切换器”,但它无处可见 . 我不确定它是否有所作为(我不知道它会如何)但我的图层存储在PostGIS数据库中,我可以在GeoServer的图层预览中查看它 . 该层位于EPSG 4326中,我知道它是OpenLayers的默认值,我将其添加到OSM底图中 . 这是我在GeoServer图层预览网址中的完整网址:

http://localhost:8080/geoserver/envision/wms?service=WMS&version=1.1.0&request=GetMap&layers=envision:basecamp_property&styles=&bbox=115.753479003906,-32.2068328857422,116.16431427002,-31.9231204986572&width=512&height=353&srs=EPSG:4326&format=application/openlayers

这是我的OpenLayers访问和添加图层的代码:

var wms = new OpenLayers.Layer.WMS('Rezoning Scenario',
                          'http://localhost:8080/geoserver/envision/wms',
                          {'layers': 'envision:basecamp_property'},
                          {isBaseLayer: false}
                      );
    map.addLayer(wms);

任何想法为什么它可能无法正常工作?

提前致谢 .

2 回答

  • 2

    最后!除了在GeoServer中从4325重新投影到900913之外,我还必须在图层属性中将投影声明为900913,如下所示:

    var wms = new OpenLayers.Layer.WMS('Rezoning Scenario',
                              'http://localhost:8080/geoserver/envision/wms',
                              {'layers': 'envision:basecamp_property'},
                              {isBaseLayer: false,
                               projection: 'EPSG:900913'} //This part was required!
                          );
        map.addLayer(wms);
    

    出于某种原因,我发现的例子并不多,但我确实做到了 .

    [R

  • 0

    这可能是因为OSM层实际上处于投影 EPSG:900913 中,因为您的WMS图层位于 EPSG:4326 中 . 由于您是WMS的管理员,您可能最容易在那里进行转换,即从您的地理服务器请求 EPSG:900913 中的WMS .

    有关更多信息,请查看这些链接:

    http://blog.sumbera.com/2010/02/17/overlay-wms-on-google-in-openlayers/

    http://osgeo-org.1560.x6.nabble.com/WMS-reprojection-td3912439.html

相关问题