[OpenLayers-Users] Changing icons in GeoRSS layer?

Gregor Mosheh gregor at hostgis.com
Thu Aug 2 21:33:34 EDT 2007


Hi, all.
I have a GeoRSS layer working; that part was easy.
Now I would like to change the icons for the markers.
Specifically, I want the marker to be determined at load time based on 
certain criteria (if category=='Restaurant' then icon=marker2.png).

I've been over the documentation, but haven't gotten anywhere yet.

I would have thought it'd be something to the effect of this:

    for (i=0; i<overlays.features.length; i++) {
       var size = new OpenLayers.Size(10,17);
       var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
       var icon = new OpenLayers.Icon('/images/marker2png',size,offset);
       overlays.features[i].marker.icon = icon;
    }

But no. Just keeps the same old icon. In fact, doing 
alert(overlays.features[i].marker.icon) shows the old URL.

I even went so far as to go beyond the icon: create a new Marker with 
the new icon and old lonlat, and set feature.marker. The only difference 
is that alert(overlays.features[i].marker.icon) shows the new icon's 
URL, even though the old icon is still drawn on the screen.

Any thoughts?

-- 
Gregor Mosheh / Greg Allensworth
System Administrator, HostGIS cartographic development & hosting services
http://www.HostGIS.com/

"Remember that no one cares if you can back up,
  only if you can restore." - AMANDA



More information about the Users mailing list