I know it's a very basic question but I've been searching for an answer for over 4 hours and I can't get it to work.

I have GeoServer running locally and I'm trying to open a layer in my browser through OpenLayers 2.

This is the code I have:

   <title>OpenLayers Example</title>
    <script src="http://openlayers.org/api/OpenLayers.js"></script>
      <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://localhost:8080/geoserver/wms", {layers: 'nurc:nyc_buildings'}     );


I copied everything exactly like the example in the OpenLayers website, only changed the URL for the layer and the layer workspace/name.

I tried changing the url to "localhost:8080/geoserver/nurc/wms" and every other possible combination, and I can't get it to work. All I can see is the "+" and "-" for zooming in and out of the layer, but the layer is blank, and sometimes it shows only pink tiles.

Firebug does not show any errors.

Any suggestions please?

  • Try adding a projection
    – Ian Turton
    Jun 14, 2015 at 11:08

1 Answer 1


I guess that your "workspace:layername" combination does not exist. If you open the OpenLayers Preview in Geoserver you will see the layername as a part of the URL like in this example "nurc:ArcSample":


Just try to use exactly the "workspace:layername" combination that you will find in the OL-Preview-URL.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.