[OpenLayers-Users] Problems trying to move a Feature (Marker)

Cúmar Cueva qmarqeva at gmail.com
Thu Apr 1 17:09:52 EDT 2010


Hi guys,

Please I need your help. I want to move a Marker (that was colocate using a
VectorLayer, that works ok), but I can't do that, yet... Here is the code:

For create the Map:

//Map
map = new OpenLayers.Map("map", {
                controls:[
                    new OpenLayers.Control.Navigation(),
new OpenLayers.Control.MousePosition(),
                    new OpenLayers.Control.Attribution(),
                    new OpenLayers.Control.Permalink(),
                    new OpenLayers.Control.PanZoomBar(),
new OpenLayers.Control.KeyboardDefaults(),
 new OpenLayers.Control.LayerSwitcher()
                    ],
                maxExtent: new
OpenLayers.Bounds(-79.23381,-3.96749,-79.17630,-4.00457),
                displayProjection: new OpenLayers.Projection("EPSG:4326"),
projection: new OpenLayers.Projection("EPSG:900913"),
                units: 'm',

                numZoomLevels: 19,
                maxResolution: 'auto'
            } );
 map.addLayer(new OpenLayers.Layer.OSM.Mapnik("Mapnik"));

And a function for move:


  function moveFeatures(vectorLayer1){

var features = vectorLayer1.features, selectedPlane = null;
   for (var i=features.length-1;i>=0;i--) {
   var feature = features[i];
   var poppedup = feature.attributes.poppedup;
   var x = feature.geometry.x + Math.cos(15 * Math.PI / 180) / 5;
   var y = feature.geometry.y + Math.sin(15 * Math.PI / 180) / 5;

if (poppedup == true) {
   selectControl.unselect(feature);
   }

   if (vectorLayer.map.getExtent().contains(x, y)) {

var newPoint = new OpenLayers.LonLat(x, y);
 feature.move(newPoint);
 if (poppedup == true) {
   selectControl.select(feature);
   }
   }
   else {
   vectorLayer.destroyFeatures([feature]);
feature.destroy();
 feature = null;
   }
   }
 //only for simulate moved
   setTimeout(function(){moveFeatures(vectorLayer, vectorLayer.features ||
[])}, 1000);
   }

I put some "alerts" in javascript for view lat and lon values, and  these
change correctly... but the Marker in the map don't move !!!! please help
me....


-- 
Atte,

Cúmar Cueva
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20100401/89bb48dc/attachment.html


More information about the Users mailing list