【问题标题】:How to add a geoserver layer to openlayers?如何将地理服务器图层添加到 openlayers?
【发布时间】:2014-12-09 10:21:10
【问题描述】:

我正在尝试在 openlayers 上添加一个带有 2 个点的地理服务器层。但我只得到没有点的地图。这是我尝试的:

     <html>
     <head>
       <title>OpenLayers Example</title>
       <script src="http://openlayers.org/api/OpenLayers.js"></script>
     </head>
     <body>
       <div style="width:100%; height:100%" id="map"></div>
       <script defer="defer" type="text/javascript">
         var map = new OpenLayers.Map('map');


        var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
          "http://vmap0.tiles.osgeo.org/wms/vmap0", {layers: 'basic'} );


         var cabin= new OpenLayers.Layer.WMS(
                "Cabins",
                "http://localhost:8080/geoserver/wms",
                {layers: "cite::obj_geom",
                    transparent: false,
                    TILED: false,
                    styles: "point"
                },
        {isBaseLayer: false,
            displayInLayerSwitcher: true,
            format: "image/png",
            visibility: false,
            displayOutsideMaxExtent: false,
            projection: new OpenLayers.Projection("EPSG:900913")

        }
      );    

    map.addLayers([wms,cabin]);
    map.zoomToMaxExtent();

  </script>

  </body>
  </html>

我做错了什么?我以为是投影,但我将其更改为 EPSG:900913,与 openlayers 地图投影相同。

【问题讨论】:

    标签: geoserver openlayers-3


    【解决方案1】:

    重新安装 geoserver 后一切正常。代码正确!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多