user1919
user1919

Reputation: 3938

How to add a geoserver layer to openlayers?

I am trying to add a geoserver layer with 2 points on the openlayers. But I only get the map without the points. This is what I try:

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

What am I doing wrong? I thought it was the projections but I changed it to EPSG:900913, the same with the openlayers map projection.

Upvotes: 0

Views: 4839

Answers (1)

user1919
user1919

Reputation: 3938

After reinstalling geoserver everything worked fine. The code is correct!

Upvotes: 1

Related Questions