[OpenLayers-Users] Different icons for popups

Arnd Wippermann arnd.wippermann at web.de
Fri Jan 30 12:12:08 EST 2009


Hi,

If your features have an attribute named attraction with the attribute value
= "attraction" or "museum", your code should display the icon. 

var lookup = {
	"attraction": //value of attribute attraction
		{externalGraphic: '../attraction.png', pointRadius: 15,
fillOpacity: 1},
      "museum": //other value of attribute attraction
		{externalGraphic: '../museum.png'}, pointRadius: 15,
fillOpacity: 1}
}

//here you name the attribute to look at and above you list the attribute
values
markerStyle.addUniqueValueRules("default", "attraction", lookup);

Your lookup object have some strange lines (copy paste issue?) and for IE
the last comma would fail.

Regards
Arnd Wippermann


-----Ursprüngliche Nachricht-----
Von: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] Im
Auftrag von bzrudi
Gesendet: Freitag, 30. Januar 2009 15:20
An: users at openlayers.org
Betreff: [OpenLayers-Users] Different icons for popups

Hi list!

I have a strange problem with applying different icons to my markers/popups
using addUniqueValueRules(). I see all the examples and read a lot but
unfortunately it doesn't work as expected, so one may help me out here
please ;-)

So what I did. Defined a styleMap as below and bind my Vectorlayer to it.

var markerStyle = new OpenLayers.StyleMap({
	externalGraphic: '../museum.png',
         fillOpacity: 1,
         pointRadius: 10,
});

vectorlayer = new OpenLayers.Layer.Vector('Infos', 
     	{displayInLayerSwitcher: true,
	styleMap: markerStyle});

This works as expected, all my markers have the "museum" icon instead of the
circle/point. I now tried to apply differnt icons to the markers/popups
using this as example:

var lookup = {
	attraction: {externalGraphic: '../attraction.png', pointRadius: 15, 
             $js .= "vectorlayer = new OpenLayers.Layer.Vector('Polygon
Layer',
                                 {displayInLayerSwitcher: true,
                                  styleMap: markerStyle});\n";
fillOpacity: 1},
         museum: {externalGraphic: '../museum.png'}, pointRadius: 15,
fillOpacity: 1},
}

and also add:

markerStyle.addUniqueValueRules("default", "attraction", lookup);

Now, instead of having all my markers using the "attraction" icon (what is
what I expected) - the markers are no longer displayed.
I tried lots of things to get rid of this but have no more idea how to.
Unfortunately I'm a PHP programmer with just basic JS knowledge. So if there
is anyone who can help, please let me know, thanks!

cheers bzrudi
_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users




More information about the Users mailing list