[OpenLayers-Commits] r11030 -
sandbox/elemoine/draw-feature/lib/OpenLayers/Handler
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Thu Jan 13 09:09:04 EST 2011
Author: erilem
Date: 2011-01-13 06:09:03 -0800 (Thu, 13 Jan 2011)
New Revision: 11030
Modified:
sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Path.js
sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Point.js
sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Polygon.js
Log:
draw first point on activate and on finalize
Modified: sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Path.js
===================================================================
--- sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Path.js 2011-01-12 13:06:30 UTC (rev 11029)
+++ sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Path.js 2011-01-13 14:09:03 UTC (rev 11030)
@@ -79,8 +79,8 @@
* feature.
*/
createFeature: function(pixel) {
- if(this.persist) {
- this.destroyFeature();
+ if(!pixel) {
+ pixel = new OpenLayers.Pixel(-50, -50);
}
var lonlat = this.control.map.getLonLatFromPixel(pixel);
this.point = new OpenLayers.Feature.Vector(
@@ -92,6 +92,9 @@
this.callback("create", [this.point.geometry, this.getSketch()]);
this.point.geometry.clearBounds();
this.layer.addFeatures([this.line, this.point], {silent: true});
+ if(this.persist) {
+ this.destroyFeature();
+ }
},
/**
@@ -233,13 +236,12 @@
* {Boolean} Allow event propagation
*/
mousemove: function (evt) {
- if(this.drawing) {
+ if(this.drawing) {
if(this.mouseDown && this.freehandMode(evt)) {
this.addPoint(evt.xy);
- } else {
- this.modifyFeature(evt.xy);
}
}
+ this.modifyFeature(evt.xy);
return true;
},
@@ -261,9 +263,6 @@
this.finalize();
} else {
if(this.lastDown.equals(evt.xy)) {
- if(this.lastUp == null) {
- this.createFeature(evt.xy);
- }
this.addPoint(evt.xy);
this.drawing = true;
this.lastUp = evt.xy;
Modified: sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Point.js
===================================================================
--- sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Point.js 2011-01-12 13:06:30 UTC (rev 11029)
+++ sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Point.js 2011-01-13 14:09:03 UTC (rev 11030)
@@ -144,6 +144,7 @@
}, this.layerOptions);
this.layer = new OpenLayers.Layer.Vector(this.CLASS_NAME, options);
this.map.addLayer(this.layer);
+ this.createFeature();
return true;
},
@@ -155,12 +156,18 @@
* pixel - {<OpenLayers.Pixel>} A pixel location on the map.
*/
createFeature: function(pixel) {
+ if(!pixel) {
+ pixel = new OpenLayers.Pixel(-50, -50);
+ }
var lonlat = this.map.getLonLatFromPixel(pixel);
this.point = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat)
);
this.callback("create", [this.point.geometry, this.point]);
this.point.geometry.clearBounds();
+ if(this.persist) {
+ this.destroyFeature();
+ }
this.layer.addFeatures([this.point], {silent: true});
},
@@ -218,6 +225,7 @@
if(cancel || !this.persist) {
this.destroyFeature();
}
+ this.createFeature();
},
/**
@@ -332,15 +340,8 @@
if(this.lastDown && this.lastDown.equals(evt.xy)) {
return true;
}
- this.drawing = true;
- if(this.lastDown == null) {
- if(this.persist) {
- this.destroyFeature();
- }
- this.createFeature(evt.xy);
- } else {
- this.modifyFeature(evt.xy);
- }
+ this.drawing = true; // FIXME is this necessary?
+ this.modifyFeature(evt.xy);
this.lastDown = evt.xy;
return !this.stopDown;
},
@@ -357,9 +358,7 @@
* {Boolean} Allow event propagation
*/
mousemove: function (evt) {
- if(this.drawing) {
- this.modifyFeature(evt.xy);
- }
+ this.modifyFeature(evt.xy);
return true;
},
@@ -375,7 +374,7 @@
* {Boolean} Allow event propagation
*/
mouseup: function (evt) {
- if(this.drawing) {
+ if(this.lastDown.equals(evt.xy)) {
this.finalize();
return !this.stopUp;
} else {
Modified: sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Polygon.js
===================================================================
--- sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Polygon.js 2011-01-12 13:06:30 UTC (rev 11029)
+++ sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Polygon.js 2011-01-13 14:09:03 UTC (rev 11030)
@@ -75,6 +75,9 @@
* feature.
*/
createFeature: function(pixel) {
+ if(!pixel) {
+ pixel = new OpenLayers.Pixel(-50, -50);
+ }
var lonlat = this.control.map.getLonLatFromPixel(pixel);
this.point = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat)
@@ -85,7 +88,7 @@
// check for hole digitizing
var polygon;
- if (this.holeModifier && (this.evt[this.holeModifier])) {
+ if (this.holeModifier && this.evt && this.evt[this.holeModifier]) {
var geometry = this.point.geometry;
var features = this.control.layer.features;
var candidate;
More information about the Commits
mailing list