Adding a 'sketchstarted' event on the vector layer. This event is triggered at the start of each new sketch. r=ahocevar (closes #1945)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@9269 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -92,10 +92,12 @@ OpenLayers.Handler.Point = OpenLayers.Class(OpenLayers.Handler, {
|
||||
* handler
|
||||
*
|
||||
* Named callbacks:
|
||||
* done - Called when the point drawing is finished. The callback will
|
||||
* recieve a single argument, the point geometry.
|
||||
* create - Called when a sketch is first created. Callback called with
|
||||
* the creation point geometry and sketch feature.
|
||||
* modify - Called with each move of a vertex with the vertex (point)
|
||||
* geometry and the sketch feature.
|
||||
* done - Called when the point drawing is finished. The callback will
|
||||
* recieve a single argument, the point geometry.
|
||||
* cancel - Called when the handler is deactivated while drawing. The
|
||||
* cancel callback will receive a geometry.
|
||||
*/
|
||||
@@ -133,11 +135,17 @@ OpenLayers.Handler.Point = OpenLayers.Class(OpenLayers.Handler, {
|
||||
/**
|
||||
* Method: createFeature
|
||||
* Add temporary features
|
||||
*
|
||||
* Parameters:
|
||||
* pixel - {<OpenLayers.Pixel>} A pixel location on the map.
|
||||
*/
|
||||
createFeature: function() {
|
||||
createFeature: function(pixel) {
|
||||
var lonlat = this.map.getLonLatFromPixel(pixel);
|
||||
this.point = new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.Point()
|
||||
new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat)
|
||||
);
|
||||
this.callback("create", [this.point.geometry, this.point]);
|
||||
this.point.geometry.clearBounds();
|
||||
this.layer.addFeatures([this.point], {silent: true});
|
||||
},
|
||||
|
||||
@@ -250,6 +258,7 @@ OpenLayers.Handler.Point = OpenLayers.Class(OpenLayers.Handler, {
|
||||
this.point.geometry.y = lonlat.lat;
|
||||
this.callback("modify", [this.point.geometry, this.point]);
|
||||
this.point.geometry.clearBounds();
|
||||
this.drawFeature();
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -308,16 +317,16 @@ OpenLayers.Handler.Point = OpenLayers.Class(OpenLayers.Handler, {
|
||||
if(this.lastDown && this.lastDown.equals(evt.xy)) {
|
||||
return true;
|
||||
}
|
||||
this.drawing = true;
|
||||
if(this.lastDown == null) {
|
||||
if(this.persist) {
|
||||
this.destroyFeature();
|
||||
}
|
||||
this.createFeature();
|
||||
this.createFeature(evt.xy);
|
||||
} else {
|
||||
this.modifyFeature(evt.xy);
|
||||
}
|
||||
this.lastDown = evt.xy;
|
||||
this.drawing = true;
|
||||
this.modifyFeature(evt.xy);
|
||||
this.drawFeature();
|
||||
return false;
|
||||
},
|
||||
|
||||
@@ -335,7 +344,6 @@ OpenLayers.Handler.Point = OpenLayers.Class(OpenLayers.Handler, {
|
||||
mousemove: function (evt) {
|
||||
if(this.drawing) {
|
||||
this.modifyFeature(evt.xy);
|
||||
this.drawFeature();
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user