Hello Diego, Am 17.05.2013 10:40, schrieb Diego M.: > Is there any way to configure OpenLayers styling method? I have a vector > layer and I would like to style the features depending on a value of a flag > variables, so I can't use rules. Lets say I have two types of features: > houses and restaurants. houses flag is "H" and restaurants flag is "R". How > can I give them a different style within a vector layer?
Yes you can :) Look at my code snippet: var styleMap_Wetter = new OpenLayers.StyleMap({ 'default':{ fontColor: "\${fcolor}", fontSize: "12pt", fontFamily: "serif", fontWeight: "bolder", labelOutlineWidth: 6, labelOutlineColor: "#F8F8F8", labelAlign: "rm", externalGraphic: "\${icon}", graphicWidth: 32px, graphicXOffset : 0, graphicYOffset : 0, graphicOpacity: 1, label: "\${text}" }}); All these "\${...}" are placeholder for attributes. They are assigned like the following example: point = new OpenLayers.Geometry.Point(lonLat.lon, lonLat.lat); var pf = new OpenLayers.Feature.Vector(point); pf.attributes = {text: stadt, fcolor: text_color, ...}; For your application that means that you do the following: point = new OpenLayers.Geometry.Point(lonLat.lon, lonLat.lat); var pf = new OpenLayers.Feature.Vector(point); switch building: { case "H" pf.attributes = {text: "House", fcolor: "#ff0000", icon: "house.png"}; break; case "R": pf.attributes = {text: "Restaurant", fcolor: "#00ff00", icon: "restaurant.png"}; break; default: break; } Based on this code snippet I build an weather card which shows for every stored station the current weather conditions: http://www.dankoweit.de/cgi-bin/metar_karte.pl?geo=1&typ=metar I hope this helps Best regards Juergen > > > > -- > View this message in context: > http://osgeo-org.1560.x6.nabble.com/Different-Styles-Within-Vector-Layer-tp5053915.html > Sent from the OpenLayers Users mailing list archive at Nabble.com. > _______________________________________________ > Users mailing list > us...@lists.osgeo.org > http://lists.osgeo.org/mailman/listinfo/openlayers-users > -- Meine stets unfertige Homepage: www.dankoweit.de _______________________________________________ Users mailing list us...@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/openlayers-users