I've been following this tutorial: http://workshop.pgrouting.org/chapters/geoext_client.html#select-the-start-and-final-destination
It contains an Openlayers.Control.DrawFeatures control defined in the following code sample. You can also see the lines where the author comments "if we want to apply a special style to the start point we should do this here". Problem is: I don't know how to apply a style in this setting and cannot find any examples using DrawFeatures control in this way.
How can I have the start point use a different style than the end point using this DrawFeatures control?
DrawPoints = OpenLayers.Class(OpenLayers.Control.DrawFeature, {
// this control is active by default
autoActivate: true,
initialize: function(layer, options) {
// only points can be drawn
var handler = OpenLayers.Handler.Point;
OpenLayers.Control.DrawFeature.prototype.initialize.apply(
this, [layer, handler, options]
);
},
drawFeature: function(geometry) {
OpenLayers.Control.DrawFeature.prototype.drawFeature.apply(
this, arguments
);
if (this.layer.features.length == 1) {
// we just draw the startpoint
// note: if we want to apply a special style to the
// start point we should do this here
} else if (this.layer.features.length == 2) {
// we just draw the finalpoint
// note: if we want to apply a special style to the
// final point we should do this here
// we have all what we need; we can deactivate ourself.
this.deactivate();
}
}
});
