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.

I'm displaying gps track data (e.g. points in time, like the path a vehicle covered) and I need to allow the user to "play back" the track, by having the markers change color one at a time in sequence. So imagine a sequence of yellow markers and then during playback I change the first one to a red marker, then the next one, etc.

I've done a prototype using point features because it seemed easier at the time to implement this with Points because I could do the following (pseudo code):

p = getpointFromLayer();  // get the yellow point from the layer
p.style = myRedStyle; // change it's style
p.layer.drawFeature(p); // redraw the feature using the red style

Now I'd like to re-do this functionality using Markers because Markers seem to generally be more flexible for other functionality, but I don't know whether it's possible to somehow change a specific marker's appearance. Any ideas?

share|improve this question
    
My experience is that Markers are way to limited to be useful. Markers are plain DIV-objects while Features are SVG. Thus the styling for Features are way more comprehensive - all things that you can do with Marker can also be done using Feature.Vector. –  Martin Algesten Nov 13 '11 at 10:01
    
I have same problem, any ideas? –  hopelephant Jan 16 '12 at 11:13
add comment

1 Answer 1

I have not tried the following code, but I am reasonably sure you should be able to change a marker's icon by simply:

marker.setUrl('http://url.of.your.icon/icon.png');

hide it:

marker.display(false);

enlarge the icon (might pixelize with certain formats):

// 2 = double the size
marker.inflate(2);

Look at source (https://github.com/openlayers/openlayers/blob/master/lib/OpenLayers/Marker.js) for more information.

share|improve this answer
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.