map projection is EPSG:900913, displayprojection for map EPSG:4326. vector layer is polygonLayer = new OpenLayers.Layer.Vector("Polygon Layer"); with draw polygoon option

with following code I get CQL_FILTER

var myLatLonSquare = polygonLayer.features[0].geometry.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:4326"));

var testArray = "WITHIN(GEOM, ";

testArray = testArray + myLatLonSquare;

testArray = testArray.replace("MULTIPOLYGON(", "POLYGON");

    "CQL_FILTER": testArray

as it's shown on the images(the site does not let me to upload images yet) it gets different location coordinates. How to solve it?

UPDATED: enter image description here

enter image description here

enter image description here

1 Answer 1


i didnt understand why did you tranform your point to 4326 to 4326? Do you think this is not the problem for wrong location?

and openlayers cql example is so good to understand it. firstly you are defining CQL parser then you can get your filter with format.read(cql.value). The last thing is that adding your features to your map... You can also add your filter in Openlayers rule and using it your vector layer as style new OpenLayers.Style(null, {rules: [rule]})


Adding projection to vector layer.

    var wgs84 = new OpenLayers.Projection("EPSG:4326");
    map.addLayer(new OpenLayers.Layer.Vector("Line Vectors", {
        style: {
            strokeColor: "blue",
            strokeWidth: 3,
            cursor: "pointer"
        eventListeners: {
            "featuresadded": dataLoaded
        projection: wgs84

i hope it helps you...

  • Thanks for your reply. I was playing with numbers 4326, 900913, 32638, but no sense.. I know this link but problem is the vector layer has wrong projection and I cannot understand how to change it... can I assign to vector layer projection while adding it to map?
    – Lazonaden
    May 12, 2012 at 20:52
  • absolutely, you can add projection to vectorlayer when adding it to map. i have updated my answer..
    – urcm
    May 12, 2012 at 21:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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