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.

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");

antennaLayer.mergeNewParams({
    "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

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

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]})

UPDATE:

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...

share|improve this answer
    
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? –  Iliaka May 12 '12 at 20:52
    
absolutely, you can add projection to vectorlayer when adding it to map. i have updated my answer.. –  Aragon May 12 '12 at 21:35
    
Thank you very much I will try it –  Iliaka May 12 '12 at 21:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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