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 have added vector layer to map

    vactorTest = new OpenLayers.Layer.Vector("Editable Features", {
strategies: [new OpenLayers.Strategy.BBOX(), saveStrategy],
projection: new OpenLayers.Projection("EPSG:900913"),
protocol: new OpenLayers.Protocol.WFS({
    srsName: "EPSG:900913",
url: "http://localhost:8080/geoserver/wfs",
featureType: "ROADS",
featureNS: "http://localhost:8080/MIA",
featurePrefix: "MIA",
geometryName: "GEOM",
version: "1.1.0"
})
});

map.addLayer(vactorTest);

And than added polygon draw control

var drawPolygon = new OpenLayers.Control.DrawFeature(
vactorTest, OpenLayers.Handler.Polygon,
{
title: "Draw Polygon",
displayClass: "olControlDrawFeaturePolygon",
multi: true
}
);

with drawn polygon I want to filter layer

testLayer.mergeNewParams({
    "CQL_FILTER": mergeFilter
});

I use within filter: WITHIN(GEOM, POLYGON((4693721.49445 672633.89194, 4560244.10812 322255.75282, 4703732.29843 422363.79257, 4693721.49445 672633.89194)))

target layer is in Georgia, and if I draw polygon near Italy than filter works....

How can I change vector projection like my layer to get right result?

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

You can serialize your data. To reproject the data when converting, you should pass the internal and external projection to the format class, then use that format to write out your data.

var format = new OpenLayers.Format.GeoJSON({
  'internalProjection': new OpenLayers.Projection("EPSG:900913"),
  'externalProjection': new OpenLayers.Projection("EPSG:4326")
});
var jsonstring = format.write(vector_layer.features);

or you can transform your fatures on your vector layer as,

var proj = new OpenLayers.Projection("EPSG:4326");
var point = new OpenLayers.LonLat(-71, 42);
map.setCenter(point.transform(proj, map.getProjectionObject()));

i hope it helps you...

share|improve this answer
    
where I have to add this code? Thanks –  Iliaka May 12 '12 at 12:27
    
the first code for adding new features to map with different projection, the second code is transforming your feature the new projection. You can add them when adding features to your map... Both of codes will take you the same conclusion. –  Aragon May 12 '12 at 21:39
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.