1

I am requesting a vector layer from GeoServer using WFS request in JSON format. I have this URL http://myip.com:8001/geoserver/workspace/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=workspace:mylayer%20layers&maxFeatures=50&outputFormat=application/json.

I want to populate my grid/table in my client side bind to the vector layer. What happens is that I won't be able to see my layers. My question is that, am I still going to use a server proxy?

I am using Tomcat 6 in Windows 7.

Try to see my code:

var vector = new OpenLayers.Layer.Vector("My Layer");
store = new GeoExt.data.FeatureStore({
    layer: vector,
    fields: [
        {name: 'name', type: 'string'},
        {name: 'description', type: 'string'}
    ],
    proxy: new GeoExt.data.ProtocolProxy({
        protocol: new OpenLayers.Protocol.HTTP({
            url: "http://myIP:8001/geoserver/workspace/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=workspace:mylayer%20layers&maxFeatures=50&outputFormat=application/json",
            format: new OpenLayers.Format.GeoJSON()
        })
    }),
    autoLoad: true
});

var gridPanel = new Ext.grid.GridPanel({
    //title: "Feature Grid",
    region: "east",
    store: store,
    width: 'auto',
    height: 100,
    columns: [{
        header: "Name",
        width: 200,
        dataIndex: "name"
    }, {
        header: "Description",
        width: 100,
        dataIndex: "description"
    }],
    sm: new GeoExt.grid.FeatureSelectionModel() 
});
2

Yes, you have to use proxy. The only format that allows cross-domain (and cross-port) access is JSONP, not pure JSON.

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.