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.

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 ?

share|improve this question
add comment

1 Answer 1

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

share|improve this answer
    
Unfortunately,when layer is redrawn,it is again re-requested and all features in the layer will be at the same position.Moving them is a way,but looping all the features is not a solution. –  Myra May 12 '13 at 18:22
1  
I know this problem. If you have not so much element on your layer (few thousands), you can use the Fixed strategy instead of BBOX. The Fixed strategy loads all the features and doesnt change them. The BBOX strategy reloads all features when the viewport changes enough to invalidate the current BBOX. btw i just work on a custom bbox strategy, that doesn't remove features, only adds new features to the requested area. –  Laposhasú Acsa May 12 '13 at 18:50
    
It is dangerous to load entire vector elements at once.Such workload could not be handled by browser.I don't think Fixed Strategy would solve my problem –  Myra May 12 '13 at 19:24
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.