2

I've adapted the working example from geo-solutions website but still it is not working, it seems the problem is with jetty. below is the previous question

I'm using Geoserver with jetty web server, I've published WMS layer in GeoServer and when i call it from QGIS it works perfectly, but when i call it with OpenLayers it is not loading, it says HTTP ERROR: 404 Not found, both my html file (with the OpenLayers script) and GeoServer are running on localhost:8083.

<html>
   <head>
         <title>Counties of enschede</title>
         <link rel="stylesheet" href="localhost:8083/www/openlayers/theme/default/style.css" type="text/css">
         <style>
                 #map-id {
                         width: 512px;
                         height: 300px;
                 }
         </style>
         <script src="localhost:8083/www/openlayers/OpenLayers.js"></script>
        </head>
        <body>
         <h1>Counties of enschede</h1>
     <div id="map-id"></div>
     <script>
             var bounds = new OpenLayers.Bounds(
                    760709.059251067, 6834146.95621378,
                     775589.940002763, 6845228.94005499
             );

             var options = {
                             controls: [],
                             maxExtent: bounds,
                             maxResolution: 0.02741796875,
                             projection: "EPSG:3857",
                             units: 'm'
             };

             map = new OpenLayers.Map('map-id', options);

             var ccounties = new OpenLayers.Layer.WMS(
                             "Map - Enschede", "http://localhost:8083/geoserver/thesis/wms",
                             {
                                     srs: 'EPSG:3857',
                                     layers: 'thesis:Ensche',
                                     styles: '',
                                     format:'image/png'
                             },
                             {singleTile: true, ratio: 1}
             );

             map.addLayer(ccounties);

             // build up all controls
             map.addControl(new OpenLayers.Control.PanZoomBar({
                     position: new OpenLayers.Pixel(2, 15)
             }));
             map.addControl(new OpenLayers.Control.Navigation());
             map.addControl(new OpenLayers.Control.Scale());
             map.addControl(new OpenLayers.Control.MousePosition());
             map.zoomToExtent(bounds);

     </script>
    </body>

1

Check that the url created by OpenLayers in your app matches the one from the 'Layer Preview' in GeoServer using the developer tools in your browser. Check the network tab.

  • I did that to check my url, and i've used also that same url, but still it is not working – user30839 Oct 31 '14 at 10:03
  • 1
    Could you paste the urls here? Or perhaps share your HTML, CSS and JS on jsfiddle? – omarkljung Nov 3 '14 at 20:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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