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


And then, 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:

    "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 then, filter works.

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

share|improve this question
up vote 8 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 features 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()));
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

Your Answer


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.