Hello everybody, I try this question in the user list, but
without any answer. So I try it here, I'm displaying a GPX
tracks with some waypoints. I'm using this:

var myStyleMap = new OpenLayers.StyleMap({
                "default": new OpenLayers.Style({
                    pointRadius: 5,
                    fillColor: "darkred",
                    strokeColor: "red",
                    strokeWidth: 4
                })
            });

var lgpx = new OpenLayers.Layer.Vector("Ruta", {
                protocol: new OpenLayers.Protocol.HTTP({
                    url: "my.gpx",
format: new OpenLayers.Format.GPX({extractWaypoints: true, extractRoutes: true, extractAttributes: true})
                }),
                strategies: [new OpenLayers.Strategy.Fixed()],
                styleMap: myStyleMap,
                projection: new OpenLayers.Projection("EPSG:4326")
            });
map.addLayer(lgpx);

This show tracks and waypoints, nice. But now I want something a bit complex,
that is have a different color to each track. So first i try to use this
var context = {
                getColor: function(feature) {
                    return "red";
                }
            };
   var myStyleMap = new OpenLayers.StyleMap({
            "default": new OpenLayers.Style({
                pointRadius: 5,
                fillColor: "darkred",
                strokeColor: "${getColor}",
                strokeWidth: 4
            },{context: context})
        });

var lgpx = new OpenLayers.Layer.Vector("Ruta", {
                protocol: new OpenLayers.Protocol.HTTP({
                    url: "my.gpx",
format: new OpenLayers.Format.GPX({extractWaypoints: true, extractRoutes: true, extractAttributes: true})
                }),
                strategies: [new OpenLayers.Strategy.Fixed()],
                styleMap: myStyleMap,
                projection: new OpenLayers.Projection("EPSG:4326")
            });
map.addLayer(lgpx);

But now, only the inside of the waypoints are rendered. So the "$getColor" is not working. This should work also here ?

Best regards
Álvaro Monares G.
_______________________________________________
Dev mailing list
d...@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-dev

Reply via email to