[OpenLayers-Dev] styleMap and GeoRSS

Dejung Gewissler dejung.gewissler at oit.state.nj.us
Mon Feb 25 17:49:54 EST 2008


Hi Devs,

I am trying to figure out the most efficient way to handle point 
features displayed with icons. We have the requirement to symbolize 
point features differently based on a particular value (pretty much what 
happens when you add a text layer with different icons). However, we 
can't have the icon path live in the same location as the data, so we 
would like to use the new Rules class to specify which icons to use 
(kind of like the example 
http://openlayers.org/dev/examples/georss-flickr.html ). Here is a code 
snippet of what we would like to do:

   var style_GeoRSS = new OpenLayers.Style();
   var selectStyle_GeoRSS = new OpenLayers.Style({pointRadius: 50});

   var ruleIncident = new OpenLayers.Rule.Comparison(
       {
           type: OpenLayers.Rule.Comparison.EQUAL_TO,
           property: "field_value1",
           value: "incident",
           symbolizer: {
               "Point": {pointRadius: 25},
               externalGraphic: "icons/incident.png"
           }
       }
   );
   var ruleRoadwork = new OpenLayers.Rule.Comparison(
       {
           type: OpenLayers.Rule.Comparison.EQUAL_TO,
           property: "field_value1",
           value: "roadwork",
           symbolizer: {
               "Point": {pointRadius: 25},
               externalGraphic: "icons/roadwork.png"
           }
       }
   );   
   // If the above rule does not apply, use a smaller pointRadius.
   var elseRule2 = new OpenLayers.Rule(
       {
           elseFilter: true,
           symbolizer: {
               "Point": {pointRadius: 25},
               externalGraphic: "openlayers/img/marker-gold.png"
           }
       }
   );

   style_GeoRSS.addRules([ruleIncident, ruleRoadwork, elseRule2]);
  
   //create the GML layer object
   var GeoRSSLayer = new OpenLayers.Layer.GeoRSS( 'GeoRSS', 'georss.xml',
       {
           visibility:true, maxResolution:5000, minResolution:1,
           styleMap: new OpenLayers.StyleMap({
               "default": style_GeoRSS,
               "select": selectStyle_GeoRSS})       
       }
   );

...but this doesn't work :(

The problem is that the rules based styling is only available for vector 
layers. Now, I could extend the GeoRSS class (which we are currently 
using with hard coded icon paths) to accept a simplified version of the 
styleMap and then set the icons src based on it .. but that seems like 
reinventing the wheel when the georss-flickr.html example works fine.

My question is... which method would be better in the long run? We will 
be pushing quite a few points across. I am aware of the limitations with 
the vector/point overlays and can already notice a small lag when adding 
a simplified GML layer to the map. What are your thoughts about choosing 
which format to display with? Are there significant issues in using 
SVG/VML to display points with icons when the simple GeoRSS class just 
uses divs with icons?

Thanks,
Dejung





More information about the Dev mailing list