On Oct 7, 2011, at 10:09 AM, Peter Peterse wrote:

> Try the next:
> 
>> ..
> 
>    var context={
>       az : function(feature) {
>          return feature.attributes.az;
>       },
>       rate : function(feature) {
>          return feature.attributes.rate;
>       }
>    };
>    var template = {
>       externalGraphic: "arrow.png",
>       rotation: "${az}",
>       graphicWidth:6,
>       graphicHeight: "${rate}"
>    }
>    var styleMap = new OpenLayers.StyleMap(new OpenLayers.Style(template,
> {context:context}));
> 
>    var vectorLayer = new OpenLayers.Layer.Vector("Simple Geometry",
> {styleMap: styleMap});
> 
>    // create a point feature
>    var points = [];
>    var p = new OpenLayers.Feature.Vector(new
> OpenLayers.Geometry.Point(-72, 42).transform(proj.latlng,
> proj.google));
> 
>    p["styleMap"] = styleMap;
>    p.attributes = {};
>    p.attributes["az"] = 76;
>    p.attributes["rate"] = 33;
>    points.push(p);
> 
> ..
> 
> I think it should work.
> 

Wow, it does work. Thanks a ton. And, it is supremely complicated. I still 
don't get why a styleMap is being assigned to the layer, only to reassign it to 
the point on the layer. And, what is the point of putting "bind values" in the 
template, but then use functions to returns values for those values. Might be 
helpful to understand the chain of commands in OL as each point's definition is 
encountered and it is rendered on the layer.

Now, I have figure out why `layer.events.on({"featureadded": function(event) 
{}});` is not working.

Puneet._______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to