Note: This is not same with: How to move OpenLayers Vector programmatically?
I have a simple openlayers map project. I need to show and move some Vectors on of it.
I create vectors like this and that works well:
var feature = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point( unit.lon,unit.lat ).transform(epsg4326, projectTo),
{description:'This is the value of<br>the description attribute'} ,
{externalGraphic: '/assets/admin/layout/img/avatar/' + unit.id + '.png', graphicHeight: 74, graphicWidth: 60, graphicXOffset:-12, graphicYOffset:-25 }
);
feature.id = unit.id;
vectorLayer.addFeatures(feature);
However i'm trying to move these vectors to some exact LonLat. I've tried lots of things. One of them is below:
var feature = vectorLayer.getFeatureById(unit.id);
movePoint(feature.point, unit.lon, unit.lat);
vectorLayer.redraw();
function movePoint(point, x, y) { point.x = x; point.y = y; point.clearBounds(); }
Other one is:
var feature = vectorLayer.getFeatureById(unit.id);
feature.geometry.move(unit.lon, unit.lat);
vectorLayer.redraw();
As i understood the last move method uses pixels differences. But i dont want to use difference. Instead of that, use directly exact longitude and latitude parameters.
So again, what is the way to move vectors/points programmatically to an exact location?
I've google maps and also OSM on my project, could the projection issue be a problem?
I just started to develop openlayers. Any help would be greatly appreciated.