[Mapbender-commits] r8846 - in trunk/mapbender/http: plugins widgets

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon May 12 06:36:36 PDT 2014


Author: hwbllmnn
Date: 2014-05-12 06:36:36 -0700 (Mon, 12 May 2014)
New Revision: 8846

Modified:
   trunk/mapbender/http/plugins/mb_digitize_widget.php
   trunk/mapbender/http/widgets/w_digitize.js
Log:
added polygon digitizing via context menu & add dialog


Modified: trunk/mapbender/http/plugins/mb_digitize_widget.php
===================================================================
--- trunk/mapbender/http/plugins/mb_digitize_widget.php	2014-05-12 13:03:21 UTC (rev 8845)
+++ trunk/mapbender/http/plugins/mb_digitize_widget.php	2014-05-12 13:36:36 UTC (rev 8846)
@@ -269,6 +269,11 @@
                 digitizingFor = $link.parent().attr('title');
                 that.activate();
             });
+            digitizeDialog.find('.digitize-polygon').bind('click', function() {
+                status = 'new-polygon';
+                digitizingFor = $link.parent().attr('title');
+                that.activate();
+            });
             menu.menu('destroy').remove();
         });
         return false;

Modified: trunk/mapbender/http/widgets/w_digitize.js
===================================================================
--- trunk/mapbender/http/widgets/w_digitize.js	2014-05-12 13:03:21 UTC (rev 8845)
+++ trunk/mapbender/http/widgets/w_digitize.js	2014-05-12 13:36:36 UTC (rev 8846)
@@ -120,6 +120,7 @@
 
             switch(this.options.type) {
                 case 'line':
+                case 'polygon':
                 for(i = 0; i < this._digitizePoints.length; ++i) {
                     var pt = this._digitizePoints[i].mousePos;
                     str_path += (i === 0) ? 'M' : 'L';
@@ -152,17 +153,31 @@
             }
 
             if(pts.length > 1) {
-                var line = this._canvas.path(str_path);
+                if(this.options.type === 'line' || this.options.type === 'polygon') {
+                    var line = this._canvas.path(str_path);
 
-                line.attr({
-                    stroke: drawOptions && (drawOptions.highlightFirst || drawOptions.highlightLast) ?
-                        this.options.lineStrokeSnapped : this.options.lineStrokeDefault,
-                    "stroke-width": drawOptions && drawOptions.highlightLast ?
-                        this.options.lineStrokeWidthSnapped : this.options.lineStrokeWidthDefault
-                });
+                    line.attr({
+                        stroke: drawOptions && (drawOptions.highlightFirst || drawOptions.highlightLast) ?
+                            this.options.lineStrokeSnapped : this.options.lineStrokeDefault,
+                        "stroke-width": drawOptions && drawOptions.highlightLast ?
+                            this.options.lineStrokeWidthSnapped : this.options.lineStrokeWidthDefault
+                    });
+                }
+
+                if(this.options.type === 'polygon') {
+                    var poly = this._canvas.path(str_path + 'Z');
+
+                    poly.attr({
+                        fill: drawOptions.highlightFirst ?
+                            this.options.polygonFillSnapped : this.options.polygonFillDefault,
+                        stroke: drawOptions.highlightFirst || drawOptions.highlightLast ?
+                            this.options.lineStrokeSnapped: this.options.lineStrokeDefault,
+                        "stroke-width": drawOptions.highlightFirst ?
+                            this.options.polygonStrokeWidthSnapped : this.options.polygonStrokeWidthDefault,
+                        opacity: this.options.opacity
+                    });
+                }
             }
-
-            return;
         }
 
         // if (pos && drawOptions && !drawOptions.highlightFirst) {
@@ -242,6 +257,7 @@
         // });
         // line.toFront();
     },
+
     _digitize: function (e) {
         var mousePos = this._map.getMousePosition(e);
         var firstPointSnapped = this._isFirstPointSnapped(mousePos)
@@ -266,12 +282,14 @@
             drawPoints: true
         });
     },
+
     _reinitialize: function (e) {
         this.element
             .unbind("click", $.proxy(this, "_reinitialize"))
         this._trigger("reinitialize", e);
         return false;
     },
+
     _addLastPoint: function (e) {
         this._trigger("lastpointadded", e);
 
@@ -310,7 +328,7 @@
                 highlightLast: lastPointSnapped,
                 drawPoints: false
             });
-            this._digitizePoints.closedPolygon = firstPointSnapped;
+            this._digitizePoints.closedPolygon = this.options.type === 'polygon' && this._digitizePoints.length > 2;
             this._digitizePoints.closedLine = lastPointSnapped;
             this._addLastPoint(e);
         }



More information about the Mapbender_commits mailing list