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 am coloring the polygon shapes of world_country. I have OpenLayers in my UI, GeoServer as server and PostGIS as db. All I want is fire this query:

select the_geom from world_country where cntryname='China'

And this query should return shape file of China, so I get it in my UI and can color it.

I am using wfs data layer to fire the query, but I am not getting the selected country. Please suggest what I am missing?

function init()

{
    $("#heatmapArea").remove();
    $('body').append('<div id="heatmapArea"></div>');

            map = new OpenLayers.Map({
                div: "heatmapArea",
                allOverlays: true,
                projection: new OpenLayers.Projection("EPSG:4326"),
                units: "m",
                numZoomLevels: 18,
                maxResolution: 156543.0339,
                maxExtent: new OpenLayers.Bounds(-20037508, -20037508,
                                                 20037508, 20037508.34)
            });

var gmap = new OpenLayers.Layer.Google("Google Streets", {numZoomLevels: 20});

      var countryLayer = new OpenLayers.Layer.WMS("Country polygon","http://10.208.22.159:8080/geoserver/wms",{'layers': 'aqp:world_country', transparent: true,}, {isBaseLayer: false, opacity: 0.3, deltaX: 0.0013, deltaY: 0.00058});

    var wfsLayer = new OpenLayers.Layer.Vector("WFS", {
            strategies: [new OpenLayers.Strategy.BBOX()],
            protocol: new OpenLayers.Protocol.WFS({
                url:  "http://10.208.22.159:8080/geoserver/wfs",
                featureType: "aqp:world_country",
               // featureNS: "http://www.openplans.org/topp"
                geometryName:"the_geom"
            }),
            styleMap: new OpenLayers.StyleMap({
                strokeWidth: 3,
                strokeColor: "#FF0000"
            }),
            filter: new OpenLayers.Filter.Logical({
                type: OpenLayers.Filter.Logical.OR,
                filters: [
                    new OpenLayers.Filter.Comparison({
                        type: OpenLayers.Filter.Comparison.EQUAL_TO,
                        property: "cntryname",
                        value: "China"
                    }),
                    new OpenLayers.Filter.Comparison({
                        type: OpenLayers.Filter.Comparison.EQUAL_TO,
                        property: "cntryname",
                        value: "India"
                    })
                ]
            })
        })

map.addLayers([gmap, countryLayer,wfsLayer]);
           map.zoomToMaxExtent();
           map.zoomIn();
           map.setCenter(new OpenLayers.Bounds(-180, -90, 180, 90).getCenterLonLat(), 3);
        }
share|improve this question

protected by whuber Jul 28 '12 at 16:10

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Browse other questions tagged or ask your own question.