[OpenLayers-Users] Dynamic markers moving on simple example but not in real project

Matt Priour mpriour at kestrelcomputer.com
Mon Dec 17 17:17:11 EST 2007


I'm attempting to use OpenLayers to display dynamically moving markers. 
The data from the markers is actually being read from a dynamically 
updating table elsewhere on the page which updates from a webservice 
every 10 seconds. I pull actually changed, new or deleted data from the 
table and then "manually" create, move or delete markers. Markers are 
being created or destroyed correctly, but just not moving.

I have created a simple example to show that I could actually have the 
markers move manually and still be in the right place when zooming and 
still have events attached to them.
http://dealmaker.dyndns.org:8080/move-markers.html

However, I have not had any luck with the markers themselves in our 
project. The OpenLayers functions seem to be doing everything properly. 
I have closely followed the code through each step in the process and 
also examined both the marker's properties and its div. The functions 
are modifying the style definition of the marker div with the correct 
coordinates. However, the map display is not refreshing. When doing DOM 
inspection, the marker divs are in their original location with the 
original left & top position values. Also the marker divs become 
permanently pinned to the window such that they show in the same 
location at all zoom levels. However, when zooming in or out, new 
correctly placed marker divs are also created. Then, the markers are 
present at wrong locations & wrong sizes and correct locations & sizes 
(until another update is fired and the marker fails to move).

here is the marker move code for both the example & the actual project:

Actual Project
-----------------                      
var mrkr = vehLayer.markers[j];
var newLon = objArray[i].X;
var newLat = objArray[i].Y;
var newLonLat = new OpenLayers.LonLat(newLon,newLat);
var newPx = vehLayer.getViewPortPxFromLonLat(newLonLat);
mrkr.moveTo(newPx);

Example
-------------------
//randomly move all the markers
for(var i=0;i<markerLayer.markers.length;i++)
{
    var mrkr=markerLayer.markers[i];
    var sign = Math.random();
    (sign<0.5)?sign=(-1):sign=1;
    var newLon = sign * Math.random() + mrkr.lonlat.lon;
    var newLat = sign * Math.random() + mrkr.lonlat.lat;
    var newLonLat = new OpenLayers.LonLat(newLon,newLat);
 
    var newPx = map.getPixelFromLonLat(newLonLat);
    mrkr.moveTo(newPx);
}

Does anyone have any idea what could be wrong with the real project such 
that the viewport is not being refreshed except when doing a zoom in or 
zoom out?
If there is anymore info I could give to help solve the problem, I'd be 
happy to give it.

-- 
*Matt Priour*
Kestrel Computer Consulting <http:%5C%5Cwww.kestrelcomputer.com>
<mailto:mpriour at kestrelcomputer.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20071217/d8db2961/attachment.html


More information about the Users mailing list