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.

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",
                "http://localhost:8081/qgis/qgis_mapserv.fcgi.exe",
                 {
                    layers: 'Water',
                    format: 'image/png',
                    map: 'D:/OSGeo4W/apps/qgis/bin/MyCity.qgs'
                 }, 
                 {
                    buffer: 1, 
                    isBaseLayer: true,
                    graphicZIndex: 1
                 }
                );

    map.addLayers([base,layer]);    

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

Any Idea?!

share|improve this question
    
does it work if you take out the OSM layer? if so it is a projection issue –  iant 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
add comment

1 Answer

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.

"apache/httpd.d/"

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

to:

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

share|improve this answer
add comment

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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