Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Please help me on how can get my map from Geoserver. I want create my country web but I can nott see it in my browser but I can see in Geoserver. Please help me I am very new openlayers and Geoserver.

<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');
       new OpenLayers.Map("map");
        var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
        map.addLayers([wms, dm_wms]);
        map.zoomToMaxExtent();
      </script>
</body>
</html>
share

2 Answers 2

Not sure how GeoJSON ended up in the mix of terms in the heading, but check out the "Preview Layers" tab in the GeoServer administration GUI. One of the preview modes is "OpenLayers". This opens up a web page with a pre-configured OpenLayers implementation with the layers that you added to GeoServer.

share

The URL you are using is wrong. Change your WMS object to:

var wms = new OpenLayers.Layer.WMS(
    "OpenLayers WMS",
    "http://localhost:8080/geoserver/wms?",
    {
        layers: "trgm:iller",
        format: "image/png"
    },
    {
        isBaseLayer: false
    }
);

You can play around with the various properties, the key thing is that the url is just the base GeoServer WMS service and then everything else you put in the first object hash. All the properties in here are appended to the WMS request.

Also, you have the line map.addLayers([wms, dm_wms]); yet you have not defined dm_wms in the code block you provided. Unless you have this defined somewhere else then your code will cause an error and you won't see a map.

share
    
How can i add dm_wms can u give some example please CHenderson –  Rusty Aug 5 '12 at 8:46
    
Looking at the code you posted it looks like you are using an example from the OpenLayers website. In which case the definition for dm_wms can be found in the example.js file. However, if you simply remove dm_wms from your map.addLayers method then the map will work. If you want background mapping then you could add OpenStreetMap layer and your WMS data will then overlay that. –  CHenderson Aug 6 '12 at 12:51

This site is currently not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .