[Mapbender-commits] r8857 - in trunk/mapbender/http: plugins widgets
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Tue May 13 07:45:18 PDT 2014
Author: hwbllmnn
Date: 2014-05-13 07:45:18 -0700 (Tue, 13 May 2014)
New Revision: 8857
Modified:
trunk/mapbender/http/plugins/mb_digitize_widget.php
trunk/mapbender/http/widgets/w_digitize.js
Log:
added moving of geometries
Modified: trunk/mapbender/http/plugins/mb_digitize_widget.php
===================================================================
--- trunk/mapbender/http/plugins/mb_digitize_widget.php 2014-05-13 14:07:03 UTC (rev 8856)
+++ trunk/mapbender/http/plugins/mb_digitize_widget.php 2014-05-13 14:45:18 UTC (rev 8857)
@@ -282,11 +282,28 @@
$(this).next().toggleClass('digitize-hidden');
});
- status = 'edit-point';
+ status = 'edit-' + feature.geometry.type.toLowerCase();
+ if(status === 'edit-linestring') {
+ // TODO consolidate this
+ status = 'edit-line';
+ }
digitizingFor = url;
editedFeature = feature;
that.activate();
+ editDialog.find('.digitize-move').bind('click', function() {
+ o.$target.mb_digitize('moveMode');
+ });
+ editDialog.find('.digitize-add-vertex').bind('click', function() {
+ o.$target.mb_digitize('addVertexMode');
+ });
+ editDialog.find('.digitize-move-vertex').bind('click', function() {
+ o.$target.mb_digitize('moveVertexMode');
+ });
+ editDialog.find('.digitize-delete-vertex').bind('click', function() {
+ o.$target.mb_digitize('deleteVertexMode');
+ });
+
menu.menu('destroy').remove();
};
};
@@ -385,6 +402,21 @@
that.activate();
};
+ var featureMoved = function() {
+ var kml = $('#mapframe1').data('kml');
+ var digit = o.$target.data('mb_digitize');
+ var pts = digit._digitizePoints;
+ if(status === 'edit-point') {
+ editedFeature.geometry.coordinates = [pts[0].pos.x, pts[0].pos.y];
+ } else {
+ editedFeature.geometry.coordinates = [];
+ $.each(pts, function(_, v) {
+ editedFeature.geometry.coordinates.push([v.pos.x, v.pos.y]);
+ });
+ }
+ kml.refresh(digitizingFor);
+ };
+
this.activate = function () {
var mode = status.match(/(new|edit)-.+/)[1];
@@ -401,7 +433,8 @@
o.type = status.match(/edit-(.+)/)[1];
o.editedFeature = editedFeature;
o.$target
- .mb_digitize(o);
+ .mb_digitize(o)
+ .bind('mb_digitizefeaturemoved', featureMoved);
}
}
if (!inProgress) {
Modified: trunk/mapbender/http/widgets/w_digitize.js
===================================================================
--- trunk/mapbender/http/widgets/w_digitize.js 2014-05-13 14:07:03 UTC (rev 8856)
+++ trunk/mapbender/http/widgets/w_digitize.js 2014-05-13 14:45:18 UTC (rev 8857)
@@ -405,6 +405,65 @@
}
},
+ pointFromEvent: function(e) {
+ var mousePos = this._map.getMousePosition(e);
+
+ return {
+ mousePos: mousePos,
+ pos: this._map.convertPixelToReal(mousePos)
+ };
+ },
+
+ startMoving: function(e) {
+ this.moving = true;
+ this.moveStartPoint = this.pointFromEvent(e);
+ this.originalDigitizePoints = this._digitizePoints;
+ },
+
+ move: function(e) {
+ if(this.moving) {
+ var self = this;
+ var pt = this.pointFromEvent(e);
+ var diff = {
+ mousePos: {
+ x: this.moveStartPoint.mousePos.x - pt.mousePos.x,
+ y: this.moveStartPoint.mousePos.y - pt.mousePos.y
+ },
+ pos: {
+ x: this.moveStartPoint.pos.x - pt.pos.x,
+ y: this.moveStartPoint.pos.y - pt.pos.y
+ }
+ };
+ this._digitizePoints = [];
+ $.each(this.originalDigitizePoints, function(_, v) {
+ self._digitizePoints.push({
+ mousePos: {
+ x: v.mousePos.x - diff.mousePos.x,
+ y: v.mousePos.y - diff.mousePos.y
+ },
+ pos: {
+ x: v.pos.x - diff.pos.x,
+ y: v.pos.y - diff.pos.y
+ }
+ });
+ });
+ this._redraw();
+ }
+ },
+
+ stopMoving: function(e) {
+ this.moving = false;
+ this._trigger("featuremoved", e);
+ },
+
+ moveMode: function() {
+ this.element
+ .bind("mousedown", $.proxy(this, 'startMoving'))
+ .bind("mousemove", $.proxy(this, 'move'))
+ .bind('mouseup', $.proxy(this, 'stopMoving'))
+ .css("cursor", "crosshair");
+ },
+
coordinatesToDigitizePoints: function(coords) {
var map = $('#mapframe1').mapbender();
if($.isArray(coords[0])) {
More information about the Mapbender_commits
mailing list