2

Yesterday I made with qgis the shapefiles of my town and now I wanted to add them in a web application I'm making with OpenLayers. The problem is that, while it loads them perfectly with the wms service, the vector layers fail to get the feature from the xml/gml file and I don't know why. I don't even get any error. Here is a some part of my code:

OpenLayers.ProxyHost = 'proxy.php?url=';

    var map = new OpenLayers.Map("map", {
        //projection: new OpenLayers.Projection('EPSG:900913'),
        projection: new OpenLayers.Projection('EPSG:3857'),
        units: 'm',
        maxResolution: 4.777314266967774,//156543.0339,
        maxExtent: new OpenLayers.Bounds(-1718.3524101391, -3513.9879361762, 3058.9618568286, 785.5949040948),
        numZoomLevels: 4
    });

var mroads = new OpenLayers.Layer.WMS( 'Major Roads', 'http://andri.ns0.it:8080/geoserver/Grottole/wms', { layers: 'Grottole:MajorRoads' }, { isBaseLayer: false, opacity: .9 });

var mRoadsVector = new OpenLayers.Layer.Vector(
            'Major Roads Vector',
        {
            projection: new OpenLayers.Projection('EPSG:3857'),
            protocol: new OpenLayers.Protocol({
                url: 'mroads.xml',
                format: new OpenLayers.Format.GML()
            }),
            strategies: [new OpenLayers.Strategy.Fixed()]
        }
        );

I believe I made everything good so far, so I really hope you can help me.

1

Ok, I found where was the problem. Of course, you have to specify which kind of protocol to use, so the correct syntax was:

protocol: new OpenLayers.Protocol.HTTP({...})

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.