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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Jul 7 02:42:50 PDT 2015


Author: syed
Date: 2015-07-07 02:42:50 -0700 (Tue, 07 Jul 2015)
New Revision: 9239

Modified:
   trunk/mapbender/http/plugins/mb_digitize_widget.php
   trunk/mapbender/http/widgets/w_digitize.js
   trunk/mapbender/lib/mb.ui.displayKmlFeatures.js
Log:
fix select feature

Modified: trunk/mapbender/http/plugins/mb_digitize_widget.php
===================================================================
--- trunk/mapbender/http/plugins/mb_digitize_widget.php	2015-07-03 14:11:14 UTC (rev 9238)
+++ trunk/mapbender/http/plugins/mb_digitize_widget.php	2015-07-07 09:42:50 UTC (rev 9239)
@@ -121,10 +121,10 @@
         '<label><input type="radio" name="marker-type" value="custom"><?php echo _mb("Custom");?></input></label></form>' +
         '<table class="digitize-style-custom"><tr><td><?php echo _mb("Symbol");?>:</td><td><input type="text" name="marker-symbol" value=""></input></td></tr>' +
         '<tr><td><?php echo _mb("Symbol size");?>:</td><td><input type="text" name="marker-size" value=""></input></td></tr>' +
-        '<tr><td><?php echo _mb("Line color");?>:</td><td><input type="color" name="stroke" value="#000000"></input></td></tr>' +
+        '<tr><td><?php echo _mb("Line color");?>:</td><td><input type="text" name="stroke" value="#000000"></input></td></tr>' +
         '<tr><td><?php echo _mb("Line opacity");?>:</td><td><div class="opacity-slider" data-name="stroke-opacity"></div></td></tr>' +
         '<tr><td><?php echo _mb("Line width");?>:</td><td><input type="text" name="stroke-width" value="1"></input></td></tr>' +
-        '<tr><td><?php echo _mb("Fill color");?>:</td><td><input type="color" name="fill" value="#ff0000"></input></td></tr>' +
+        '<tr><td><?php echo _mb("Fill color");?>:</td><td><input type="text" name="fill" value="#ff0000"></input></td></tr>' +
         '<tr><td><?php echo _mb("Fill opacity");?>:</td><td><div class="opacity-slider" data-name="fill-opacity"></div></td></tr></table>' +
         '<table class="digitize-style-predefined"><tr><td><?php echo _mb("Symbol");?>:</td><td><input type="text" name="marker-symbol" value=""></input></td></tr>' +
         '<tr><td><?php echo _mb("Symbol size");?>:</td><td><select name="marker-size" value="medium"><option value="large"><?php echo _mb("large");?></option><option value="medium" selected="selected"><?php echo _mb("medium");?></option><option value="small"><?php echo _mb("small");?></option></select></td></tr>' +
@@ -275,6 +275,7 @@
                 status = 'none';
                 $('#mapframe1').data('mb_digitize').destroy();
             }
+                // digit.modeOff();
         });
 
         editStyleDialog = $(editStyleHtml);
@@ -286,6 +287,7 @@
         }).bind('dialogclose', function() {
             button.stop();
             $(this).find('input').unbind('change');
+
         });
 
         editStyleDialog.find('div.opacity-slider').slider({
@@ -542,9 +544,9 @@
     feature.properties.updated = new Date().toISOString();
     kml.refresh(url);
 });
-editStyleDialog.find('input[name="fill"]').spectrum({showInput: true});
-editStyleDialog.find('input[name="stroke"]').spectrum({showInput: true});
-editStyleDialog.find('input[name="marker-color"]').spectrum({showInput: true});
+editStyleDialog.find('input[name="fill"]').spectrum({showInput: true, showInitial: true});
+editStyleDialog.find('input[name="stroke"]').spectrum({showInput: true, showInitial: true});
+editStyleDialog.find('input[name="marker-color"]').spectrum({showInput: true, showInitial: true});
 editStyleDialog.find('input').change();
 if(menu)
     menu.menu('destroy').remove();
@@ -820,6 +822,7 @@
             editDialog.find('.digitize-pencil').bind('click', function() {
                 $(this).next().toggleClass('digitize-hidden');
             });
+
             editDialog.find('.digitize-remove').bind('click', function() {
                 if(confirm('<?php echo _mb("Do you really want to delete this feature? If you have no other copy all information will be lost. There is no backup option!");?>')) {
                     var kml = $('#mapframe1').data('kml');
@@ -844,6 +847,9 @@
             editedFeature = feature;
             that.activate();
 
+            editDialog.parent().find('a > span.ui-icon-closethick').bind('click', function() {
+                o.$target.mb_digitize('modeOff');
+            });
             editDialog.find('.digitize-move').bind('click', function() {
                 o.$target.mb_digitize('moveMode');
                 $(this).addClass('active').siblings().removeClass('active');
@@ -875,7 +881,14 @@
     };
 
     var contextmenuLayer = function() {
-        var $link = $(this);
+
+        var $link;
+        if ($(this).get(0).tagName == 'A') {
+            $link = $(this);
+        } else {
+            $link = $(this).parent().find('a')[0];
+            $link = $($link);
+        }
         var menu = $(folderMenu);
         // check if the dialog is already open
         if ( $( '.digitize-contextmenu' ).length != 0 ) {
@@ -976,6 +989,7 @@
             kml.addGeometry(pts, digitizingFor, attributesDialog);
             attributesDialog.find('.digitize-save').unbind('click');
             attributesDialog.dialog('close');
+            // digit.modeOff()
         });
     }
 };
@@ -985,7 +999,7 @@
     that.deactivate();
     that.activate();
 };
-//TODO: exchange the use of proj4js with postgis transform funktion!
+
 var featureModified = function() {
 
     var kml = $('#mapframe1').data('kml');
@@ -1157,6 +1171,7 @@
     };
 
     this.closeEditDialog = function() {
+        console.log( editDialog );
         editDialog.dialog('close');
     };
 

Modified: trunk/mapbender/http/widgets/w_digitize.js
===================================================================
--- trunk/mapbender/http/widgets/w_digitize.js	2015-07-03 14:11:14 UTC (rev 9238)
+++ trunk/mapbender/http/widgets/w_digitize.js	2015-07-07 09:42:50 UTC (rev 9239)
@@ -460,12 +460,13 @@
     },
 
     moveVertexMode: function() {
+        this.modeOff();
         this.addingVertex = false;
         this.element
-            .unbind('mousedown').unbind('mousemove').unbind('mouseup')
-            .bind('mousedown', $.proxy(this, 'startVertexMoving'))
-            .bind('mousemove', $.proxy(this, 'vertexMove'))
-            .bind('mouseup', $.proxy(this, 'stopVertexMoving'))
+            // .unbind('mousedown').unbind('mousemove').unbind('mouseup')
+            .bind('mousedown', this.startVertexMovingProxy)
+            .bind('mousemove', this.vertexMoveProxy)
+            .bind('mouseup', this.stopVertexMovingProxy)
             .css('cursor', 'crosshair');
     },
 
@@ -531,10 +532,23 @@
     },
 
     modeOff: function() {
+        // this.element
+        //     .unbind('mousedown').unbind('mousemove').unbind('mouseup').unbind('click', this.addPointProxy);
         this.element
-            .unbind('mousedown').unbind('mousemove').unbind('mouseup').unbind('click', this.addPointProxy);
+            .unbind('mousedown',this.startVertexMovingProxy)
+            .unbind('mousedown',this.addVertexProxy)
+            .unbind('mousedown',this.deleteVertexProxy)
+            .unbind('mousedown',this.startMovingProxy)
+            .unbind('mousemove',this._digitizeProxy)
+            .unbind('mousemove',this.vertexMoveProxy)
+            .unbind('mousemove',this.moveProxy)
+            .unbind('mouseup',this.stopVertexMovingProxy)
+            .unbind('mouseup',this.stopMovingProxy)
+            .unbind('click', this.addPointProxy);
         this.addingVertex = false;
         this._redraw();
+        // this.deactivate();
+        // this.destroy();
     },
 
     coordinatesToDigitizePoints: function(coords) {
@@ -569,7 +583,21 @@
     _create: function () {
         this.reinitializeProxy = $.proxy(this._reinitialize, this);
         this.addPointProxy = $.proxy(this._addPoint, this);
+        // mousedown handler
+        this.startVertexMovingProxy = $.proxy(this.startVertexMoving, this);
+        this.addVertexProxy = $.proxy(this.addVertex, this);
+        this.deleteVertexProxy = $.proxy(this.deleteVertex, this);
+        this.startMovingProxy = $.proxy(this.startMoving, this);
+        // mousemove handler
+        this._digitizeProxy = $.proxy(this._digitize, this);
+        this.vertexMoveProxy = $.proxy(this.vertexMove, this);
+        this.moveProxy = $.proxy(this.move, this);
+        //mouseup handler
+        this.stopVertexMovingProxy = $.proxy(this.stopVertexMoving, this);
+        this.stopMovingProxy = $.proxy(this.stopMoving, this);
 
+
+
         this._digitizePoints = [];
 
         // ":maps" is a Mapbender selector which
@@ -598,6 +626,7 @@
             .unbind("mousemove", this._digitize)
             .unbind("click", this.reinitializeProxy)
             .css("cursor", "default");
+
     },
     // delete everything
     destroy: function () {

Modified: trunk/mapbender/lib/mb.ui.displayKmlFeatures.js
===================================================================
--- trunk/mapbender/lib/mb.ui.displayKmlFeatures.js	2015-07-03 14:11:14 UTC (rev 9238)
+++ trunk/mapbender/lib/mb.ui.displayKmlFeatures.js	2015-07-07 09:42:50 UTC (rev 9239)
@@ -72,7 +72,6 @@
             var res = map.getScale() / mb_resolution / 100;
 
             if (!self.queriedLayer) return;
-
             var matchedIds = self.findFeatures(pos);
 
             self.updateSelectedFeatures(matchedIds, e.ctrlKey);
@@ -132,6 +131,10 @@
         }
         this.creatingPhase = false;
         this.render();
+        // // save the eventHandlers
+        // var kmlEventHandlers = $.extend(true,{}, $('#mapframe1').data('events'));
+        // var kmlEventHandlersObj = {kmlEventHandlers: kmlEventHandlers};
+        // $.extend($('#mapframe1').data(), kmlEventHandlersObj);
     },
 
     _init: function() {
@@ -187,12 +190,21 @@
                 }
             });
         });
-
         return matchedIds;
     },
 
-    inBox: function(minx, miny, maxx, maxy, x, y) {
-        return minx < x && maxx > x && miny < y && maxy > y;
+
+    inBox: function(minx, miny, maxx, maxy, selectBoxMinx, selectBoxMaxx, selectBoxMiny, selectBoxMaxy) {
+
+        // Erster Punk (minx,miny)
+        // Zweiter Punk (maxx,maxy)
+        if ( ( minx >= selectBoxMinx && minx <= selectBoxMaxx ) || ( miny >= selectBoxMiny && miny <= selectBoxMaxy )) {
+            return true;
+        }
+        if ( ( maxx >= selectBoxMinx && maxx <= selectBoxMaxx ) || ( maxy > selectBoxMiny && maxy < selectBoxMaxy )) {
+            return true;
+        }
+        return false;
     },
 
     matchFeatureToPoint: function(feat, clickPoint, matchedIds, res, itm, wgspt, idx) {
@@ -239,31 +251,37 @@
                 });
                 return;
             }
-            if (wgsbox.min.x < box[0] && wgsbox.max.x > box[2]) {
-                if (wgsbox.min.y > box[1] && wgsbox.min.y < box[3] || wgsbox.max.y > box[1] && wgsbox.max.y < box[3]) {
-                    matchedIds.push({
-                        url: itm.url,
-                        id: idx
-                    });
-                    return;
-                }
-            }
-            if (wgsbox.min.y < box[1] && wgsbox.max.y > box[3]) {
-                if (wgsbox.min.x > box[0] && wgsbox.min.x < box[2] || wgsbox.max.x > box[0] && wgsbox.max.x < box[2]) {
-                    matchedIds.push({
-                        url: itm.url,
-                        id: idx
-                    });
-                    return;
-                }
-            }
-            if (wgsbox.min.x < box[0] && wgsbox.max.x > box[2] && wgsbox.min.y > box[1] && wgsbox.max.y < box[3]) {
+            if ( this.inBox(box[0], box[1], box[2], box[3], wgsbox.min.x, wgsbox.max.x, wgsbox.min.x, wgsbox.max.x) ) {
                 matchedIds.push({
                     url: itm.url,
                     id: idx
                 });
-                return;
             }
+            // if (wgsbox.min.x < box[0] && wgsbox.max.x > box[2]) {
+            //     if (wgsbox.min.y > box[1] && wgsbox.min.y < box[3] || wgsbox.max.y > box[1] && wgsbox.max.y < box[3]) {
+            //         matchedIds.push({
+            //             url: itm.url,
+            //             id: idx
+            //         });
+            //         return;
+            //     }
+            // }
+            // if (wgsbox.min.y < box[1] && wgsbox.max.y > box[3]) {
+            //     if (wgsbox.min.x > box[0] && wgsbox.min.x < box[2] || wgsbox.max.x > box[0] && wgsbox.max.x < box[2]) {
+            //         matchedIds.push({
+            //             url: itm.url,
+            //             id: idx
+            //         });
+            //         return;
+            //     }
+            // }
+            // if (wgsbox.min.x < box[0] && wgsbox.max.x > box[2] && wgsbox.min.y > box[1] && wgsbox.max.y < box[3]) {
+            //     matchedIds.push({
+            //         url: itm.url,
+            //         id: idx
+            //     });
+            //     return;
+            // }
         }
     },
 
@@ -285,21 +303,24 @@
                     self.selectedFeatures.push(v);
                 }
             });
-
             $('.kmltree-selected').removeClass('kmltree-selected');
-            $.each(self.selectedFeatures, function(_, v) {
-                $('li[title="' + v.url + '"] li[idx="' + v.id + '"]').addClass('kmltree-selected');
-            });
+            // console.log( self.selectedFeatures );
 
 
             $('#selection-dialog').dialog('destroy').remove();
 
             if (self.selectedFeatures.length == 0) {
                 Mapbender.modules.digitize_widget.closeEditDialog();
+                // self.markFeatureInLayerTree();
             }
 
             if (self.selectedFeatures.length > 1) {
                 Mapbender.modules.digitize_widget.closeEditDialog();
+                // $.each(self.selectedFeatures, function(_, v) {
+                //     console.log( _, v );
+                //     $('li[title="' + v.url + '"] li[idx="' + v.id + '"]').addClass('kmltree-selected');
+                // });
+                self.markFeatureInLayerTree();
                 var dlg = $(self.selectionDialog);
                 var list = dlg.find('#selected-features-list')
                     .html('');
@@ -374,6 +395,13 @@
         map.setMapRequest();
     },
 
+    markFeatureInLayerTree: function(){
+        var self = this;
+        $.each(self.selectedFeatures, function(_, v) {
+            $('li[title="' + v.url + '"] li[idx="' + v.id + '"]').addClass('kmltree-selected');
+        });
+    },
+
     zoomToLayer: function(url) {
         var bbox = this.getLayerBbox(url);
         if (!bbox) {



More information about the Mapbender_commits mailing list