Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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()

    $('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","",{'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:  "",
                featureType: "aqp:world_country",
               // featureNS: ""
            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.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 or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

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

Browse other questions tagged or ask your own question.