[GIS] How to add offset to layer in OpenLayers

javascriptopenlayers-2

As the title suggests,I have GeoJSON vectors on OpenLayers map where user should add X/Y offset (i.e 5 meters north,5 meters east).I plan to add some control for it.

Since vectors are drawn map with OpenLayers.Rule object,as I searched for some offset option,then all I found was graphicXOffset & graphicYOffset which eludes normal vectors but only used for external graphics.

Is there any easy way to accomplish this feature on client ?

Best Answer

Did you try the feature's move(x,y) method?

You can attach a callback on your control's click event, that calls a function like this:

moveAllFeatures = function(layer,x,y){
  var all = layer.features.length;
  for(var i = 0;i<all;i++){
   layer.features[i].geometry.move(x,y);
  }
  layer.redraw();
}

OpenLayers geometry move