I have a project with 3 layers , I see the layers names in the GetCapabilies and also as WMS layer in QGIS , But in Openlayers I get the tile empty.

I've used the following code :

var P4326 = new OpenLayers.Projection("EPSG:4326");
    var P900913 = new OpenLayers.Projection("EPSG:900913");
    var center = new OpenLayers.LonLat(34.87726678, 32.04670294).transform(P4326, P900913);
    var extent = new OpenLayers.Bounds(34.865,32.042,34.890,32.054).transform(P4326, P900913);
    var zoom = 15;
    var map, layer;

    function init() {           

    var options = {
            controls: [

                    new OpenLayers.Control.Navigation(),
                    new OpenLayers.Control.ScaleLine(),
                    new OpenLayers.Control.PanZoomBar(),
                    new OpenLayers.Control.LayerSwitcher(),                 
                    new OpenLayers.Control.MousePosition()
        maxExtent: extent,
        restrictedExtent: extent,           
        displayProjection: P4326

    map = new OpenLayers.Map("map",options);
    var layerOptions = { zoomOffset: 11, resolutions: [76.4370282714844, 38.2185141357422, 19.1092570678711, 9.55462853393555, 4.77731426696777, 2.388657133483885, 1.194328566741943, 0.5971642833709715] };
    var base = new OpenLayers.Layer.OSM("Base", "", layerOptions);

     layer = new OpenLayers.Layer.WMS("WMS",
                    layers: 'Water',
                    format: 'image/png',
                    map: 'D:/OSGeo4W/apps/qgis/bin/MyCity.qgs'
                    buffer: 1, 
                    isBaseLayer: true,
                    graphicZIndex: 1


And only the OSM layer show , when I switch to the WMS , nothing shown.

Any Idea?!

  • does it work if you take out the OSM layer? if so it is a projection issue – Ian Turton Jan 28 '13 at 12:39
  • No it doesn't , and it also doesn't work if I use: localhost/qgis/… – Alophind Jan 28 '13 at 13:24

This answer may be late. But you have had the same problem like i did.

I guess you've followed one of the tutorials that are out there in the web. Following one of them tells you to download the osgeo4w apache server and you're probably running your website on a xampp apache or any other apache server since your url is localhost. What you're gonna have to do is this:

3c. If you do not want to use the osgeo-apache and already have your own apache running, just create a directory in the apache-dir, e.g.


and copy the httpd_qgis.conf file into this directory, then add the following section to the httpd.conf of your apache. Place this at the end of the config-file and ensure bot to be in any subsection (subsections appear like this <[sectionsname]> and end with

# parse other apache conf files include "C:[YOURPATHTOYOURAPACHEINSTALLATION]\httpd.d\httpd_*.conf"

Then open your apache's httpd.conf and edit these lines:

# Controls who can get stuff from this server.
Require all granted


# Controls who can get stuff from this server.
Order allow,deny
Allow from all

Then your layer should work.

If it doesnt, you can copy your qgis folder from the osgeo4w path to the htdocs folder of your site's apache.

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.