[Mapbender-commits] r8861 - trunk/mapbender/http/widgets
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Wed May 14 01:45:08 PDT 2014
Author: hwbllmnn
Date: 2014-05-14 01:45:08 -0700 (Wed, 14 May 2014)
New Revision: 8861
Modified:
trunk/mapbender/http/widgets/w_digitize.js
Log:
added vertex adding
Modified: trunk/mapbender/http/widgets/w_digitize.js
===================================================================
--- trunk/mapbender/http/widgets/w_digitize.js 2014-05-14 08:03:26 UTC (rev 8860)
+++ trunk/mapbender/http/widgets/w_digitize.js 2014-05-14 08:45:08 UTC (rev 8861)
@@ -162,7 +162,7 @@
this.options.lineStrokeSnapped : this.options.lineStrokeDefault,
"stroke-width": drawOptions && drawOptions.highlightLast ?
this.options.lineStrokeWidthSnapped : this.options.lineStrokeWidthDefault
- });
+ })
}
if(this.options.type === 'polygon') {
@@ -179,6 +179,24 @@
});
}
}
+ if(this.addingVertex) {
+ var last;
+ for(i = 0; i < this._digitizePoints.length; ++i) {
+ var pt = this._digitizePoints[i].mousePos;
+ if(last) {
+ var x = last.x + (pt.x - last.x) / 2;
+ var y = last.y + (pt.y - last.y) / 2;
+ this._canvas.circle(x, y, this.options.digitizePointDiameter)
+ .attr({
+ fill: this.options.pointFillSnapped,
+ "fill-opacity": this.options.opacity,
+ stroke: this.options.pointStrokeSnapped,
+ "stroke-width": this.options.pointStrokeWidthDefault
+ });
+ }
+ last = pt;
+ }
+ }
}
// if (pos && drawOptions && !drawOptions.highlightFirst) {
@@ -491,6 +509,38 @@
.css('cursor', 'crosshair');
},
+ addVertex: function(e) {
+ var pt = this.pointFromEvent(e);
+ var last;
+ for(var i = 0; i < this._digitizePoints.length; ++i) {
+ if(last) {
+ var cur = new Mapbender.Point(
+ last.mousePos.x + (this._digitizePoints[i].mousePos.x - last.mousePos.x) / 2,
+ last.mousePos.y + (this._digitizePoints[i].mousePos.y - last.mousePos.y) / 2
+ );
+
+ if(this._isPointSnapped(cur, pt.mousePos)) {
+ this._digitizePoints.splice(i, 0, pt);
+ this.vertexMoving = true;
+ this.vertexMovingIndex = i;
+ return;
+ }
+ }
+ last = this._digitizePoints[i];
+ }
+ },
+
+ addVertexMode: function() {
+ this.addingVertex = true;
+ this.element
+ .unbind('mousedown').unbind('mousemove').unbind('mouseup')
+ .bind('mousedown', $.proxy(this, 'addVertex'))
+ .bind('mousemove', $.proxy(this, 'vertexMove'))
+ .bind('mouseup', $.proxy(this, 'stopVertexMoving'))
+ .css('cursor', 'crosshair');
+ this._redraw();
+ },
+
deleteVertex: function(e) {
var pt = this.pointFromEvent(e);
var self = this;
More information about the Mapbender_commits
mailing list