Indeed, the patch was missing.
Here it is.

On Fri, Sep 16, 2011 at 5:23 PM, Andreas Hocevar <[email protected]> wrote:
> Hey Pierre,
>
> I like this change, and I don't think you need a ticket and review for 
> changing an example. Just make sure that you modify the example description 
> accordingly as well.
>
> Andreas.
>
> On Sep 16, 2011, at 08:04 , Pierre Giraud wrote:
>
>> Hi all,
>>
>> With the following patch, I would like to modify the "feature-grid"
>> example to show how we can simply add a new column with a
>> FeatureRenderer.
>> Can someone please review it? I can open a ticket if required.
>>
>> http://yfrog.com/nv5i4p
>>
>> Thanks,
>> Pierre
>>
>> --
>> Pierre GIRAUD
>> Géomaticien, Analyste
>>
>> Camptocamp France SAS
>> Savoie Technolac, BP 352
>> 73377 Le Bourget du Lac, Cedex
>>
>> Tel : 00 33 4 79 44 44 93
>> Mail : [email protected]
>> http://www.camptocamp.com
>> _______________________________________________
>> Dev mailing list
>> [email protected]
>> http://www.geoext.org/cgi-bin/mailman/listinfo/dev
>
>
>
> --
> Andreas Hocevar
> OpenGeo - http://opengeo.org/
> Expert service straight from the developers.
>
>



-- 
Pierre GIRAUD
Géomaticien, Analyste

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 93
Mail : [email protected]
http://www.camptocamp.com
Index: feature-grid.html
===================================================================
--- feature-grid.html	(revision 2838)
+++ feature-grid.html	(working copy)
@@ -23,6 +23,9 @@
         GeoExt feature selection model is also used so that selecting rows in 
         the grid selects features in the layer, and vice-versa.</p> 
 
+        <p>In this example, you will also find a example usage of the 
+        GeoExt.FeatureRenderer component.</p>
+
         <p>See <a href=feature-grid.js>feature-grid.js</a>.</p>
 
         <div id="mainpanel"></div>
Index: feature-grid.js
===================================================================
--- feature-grid.js	(revision 2838)
+++ feature-grid.js	(working copy)
@@ -24,7 +24,32 @@
     );
 
     // create vector layer
-    var vecLayer = new OpenLayers.Layer.Vector("vector");
+    var context = {
+        getColor: function(feature) {
+            if (feature.attributes.elevation < 2000) {
+                return 'green';
+            }
+            if (feature.attributes.elevation < 2300) {
+                return 'orange';
+            }
+            return 'red';
+        }
+    };
+    var template = {
+        fillOpacity: 0.5,
+        fillColor: "${getColor}",
+        pointRadius: 5,
+        strokeWidth: 1,
+        strokeOpacity: 1,
+        strokeColor: "${getColor}",
+        graphicName: "triangle"
+    };
+    var style = new OpenLayers.Style(template, {context: context});
+    var vecLayer = new OpenLayers.Layer.Vector("vector", {
+        styleMap: new OpenLayers.StyleMap({
+            'default': style
+        })
+    });
     map.addLayers([wmsLayer, vecLayer]);
 
     // create map panel
@@ -54,6 +79,40 @@
         autoLoad: true
     });
 
+    function getSymbolTypeFromFeature(feature){
+        var type;
+        switch (feature.geometry.CLASS_NAME) {
+            case "OpenLayers.Geometry.MultiLineString":
+            case "OpenLayers.Geometry.LineString":
+                type = 'Line';
+                break;
+            case "OpenLayers.Geometry.Point":
+                type = 'Point';
+                break;
+            case "OpenLayers.Geometry.Polygon":
+                type = 'Polygon';
+                break;
+        }
+        return type;
+    }
+
+    function renderFeature(value, p, r) {
+        var id = Ext.id(),
+            feature = r.get('feature');
+
+        (function() {
+            var symbolizer = r.store.layer.styleMap.createSymbolizer(feature, 'default');
+            var renderer = new GeoExt.FeatureRenderer({
+                renderTo: id,
+                width: 12,
+                height: 12,
+                symbolType: getSymbolTypeFromFeature(feature),
+                symbolizers: [symbolizer]
+            });
+        }).defer(25);
+        return (String.format('<div id="{0}"></div>', id));
+    }
+
     // create grid panel configured with feature store
     gridPanel = new Ext.grid.GridPanel({
         title: "Feature Grid",
@@ -61,6 +120,11 @@
         store: store,
         width: 320,
         columns: [{
+            header: "",
+            width: 30,
+            renderer: renderFeature,
+            dataIndex: 'fid'
+        },{
             header: "Name",
             width: 200,
             dataIndex: "name"
_______________________________________________
Dev mailing list
[email protected]
http://www.geoext.org/cgi-bin/mailman/listinfo/dev

Reply via email to