[OpenLayers-Users] Changing icons in GeoRSS layer?

Holmes, Charles V. cholmes at mitre.org
Fri Aug 3 08:42:54 EDT 2007


OpenLayers.Layer.GeoRSS inherets from OpenLayers.Layer.Markers
(http://dev.openlayers.org/docs/files/OpenLayers/Layer/Markers-js.html#
OpenLayers.Layer.Markers).  Trying to add the marker with the addMarker
method will probably solve your problem.  

var layer = new OpenLayers.Layer.GeoRSS(...)
var marker = new OpenLayers.Marker(
		new OpenLayers.LonLat(y,x), 
		  new OpenLayers.Icon(
		  path, // e.g.
"http://openlayers.org/api/img/marker.png" 
		   new OpenLayers.Size(img_w,img_h)
		  )); 
Layer.addMarker(marker)

--
Charles

-----Original Message-----
From: users-bounces at openlayers.org
[mailto:users-bounces at openlayers.org] On Behalf Of Gregor Mosheh
Sent: Thursday, August 02, 2007 9:34 PM
To: openlayers user list
Subject: [OpenLayers-Users] Changing icons in GeoRSS layer?

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
_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users



More information about the Users mailing list