[OpenLayers-Users] Dynamically moving markers?

Juuso Räsänen juuso.rasanen at hotmail.com
Tue Jun 9 03:33:50 EDT 2009


Hello all,

I would like to create a map with dynamically moving markers (or features). So something like this...
http://transport.wspgroup.fi/hklkartta/

...
but much simpler (at least in the beginning) and, of course, utilizing
OpenLayers insted of GMaps. Well, Have you seen ANYTHING similar
implemented with OpenLayers? Any, even very simple, examples? For me it
seems that OpenLayers doesn't provide any (higher level) APIs for
doing things like that.. Correct?

I did some proof-of-concept
tests by periodically calling the following function. It works :), but
of course there is a lot of coding todo.. :|

// A function for moving marker to specified lonlat location.

//  OpenLayers seems to provide only pixel-based moveTo - method...

function setLonLat(marker, lonlat) {

     if (lonlat != null) {

         marker.lonlat = lonlat;

         if (marker.map != null) {

         var px = marker.map.getLayerPxFromLonLat(marker.lonlat);

             if (px != null) {

                 marker.draw(px);

             }

         }

     }

}


BR,
 - Juuso

PS. Some previous discussions I went through around the topic:
http://n2.nabble.com/Dynamic-markers-moving-on-simple-example-but-not-in-real-project-td1829702.html
http://www.mail-archive.com/mapbuilder-devel@lists.sourceforge.net/msg00363.html

_________________________________________________________________
Show them the way! Add maps and directions to your party invites. 
http://www.microsoft.com/windows/windowslive/products/events.aspx


More information about the Users mailing list