[OpenLayers-Users] Different icons for popups

bzrudi bzrudi at centarea.com
Sat Jan 31 02:42:06 EST 2009


Hi,

stupid me. I found the problem. Thanks to your advice that the code 
should work I looked around and found that I just forget to add the 
'attraction' attribute to the 'propertyName' list of my WFS request.

And thanks for your advice with the last comma, hopefully there are no 
more IE quirks to come around once I will test it;-)

Thanks again!
cheers bzrudi

Arnd Wippermann wrote:
> 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