[Mapbender-commits] r8972 - in trunk/mapbender: http/css http/plugins lib

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Jul 2 04:18:23 PDT 2014


Author: hwbllmnn
Date: 2014-07-02 04:18:23 -0700 (Wed, 02 Jul 2014)
New Revision: 8972

Modified:
   trunk/mapbender/http/css/digitize_new.css
   trunk/mapbender/http/plugins/mb_digitize_widget.php
   trunk/mapbender/lib/mb.ui.displayKmlFeatures.js
Log:
added multiple selection & selection dialog for features, exporting of selected features


Modified: trunk/mapbender/http/css/digitize_new.css
===================================================================
--- trunk/mapbender/http/css/digitize_new.css	2014-07-02 09:20:10 UTC (rev 8971)
+++ trunk/mapbender/http/css/digitize_new.css	2014-07-02 11:18:23 UTC (rev 8972)
@@ -211,3 +211,7 @@
 label > input[type="radio"] {
     height: 50px;
 }
+
+#selected-features-list {
+    list-style-type: none;
+}

Modified: trunk/mapbender/http/plugins/mb_digitize_widget.php
===================================================================
--- trunk/mapbender/http/plugins/mb_digitize_widget.php	2014-07-02 09:20:10 UTC (rev 8971)
+++ trunk/mapbender/http/plugins/mb_digitize_widget.php	2014-07-02 11:18:23 UTC (rev 8972)
@@ -157,13 +157,6 @@
                      + '</form>'
                      + '</div>';
 
-    var selectionDialog = '<div id="selection-dialog" title="Selected features">'
-                          + '<ul id="selected-features-list">'
-                          + '</ul>'
-                          + '<div class="digitize-image digitize-remove"></div>'
-                          + '<div class="digitize-image digitize-export"></div>'
-                          + '</div>';
-
     var digitizeDialog,
         editDialog,
         attributesDialog,
@@ -269,6 +262,8 @@
         });
 
         $('#mapframe1').bind('kml:loaded', function(evt, item) {
+            var kml = $('#mapframe1').data('kml');
+            kml.exportItem = exportItem;
             var url = item.url;
             $('li[title="' + url + '"] > a').die('contextmenu').live('contextmenu', contextmenuLayer);
             $('li[title="' + url + '"] > ul > li').die('contextmenu').live('contextmenu', contextmenuObject)

Modified: trunk/mapbender/lib/mb.ui.displayKmlFeatures.js
===================================================================
--- trunk/mapbender/lib/mb.ui.displayKmlFeatures.js	2014-07-02 09:20:10 UTC (rev 8971)
+++ trunk/mapbender/lib/mb.ui.displayKmlFeatures.js	2014-07-02 11:18:23 UTC (rev 8972)
@@ -47,6 +47,13 @@
     kmlOrder: [],
     _popup : null,
     creatingPhase: true,
+    selectedFeatures: [],
+    selectionDialog: '<div id="selection-dialog" title="Selected features">'
+                   + '<ul id="selected-features-list">'
+                   + '</ul>'
+                   + '<div class="digitize-image digitize-remove"></div>'
+                   + '<div class="digitize-image digitize-export"></div>'
+                   + '</div>',
 
     _create: function(){
         var self = this, o = this.options;
@@ -84,9 +91,55 @@
                     }
                 });
             });
+            if(matchedIds.length == 1 && !e.ctrlKey && self.selectedFeatures.length == 0) {
+                $('li[title="' + matchedIds[0].url + '"] li[idx="' + matchedIds[0].id + '"]').click();
+            } else {
+                if(!e.ctrlKey) {
+                    self.selectedFeatures = [];
+                }
+                $.each(matchedIds, function(_, v) {
+                    var contained = false;
+                    $.each(self.selectedFeatures, function(_, sel) {
+                        if(v.url == sel.url && v.id == sel.id) contained = true;
+                    });
+                    if(!contained) {
+                        self.selectedFeatures.push(v);
+                    }
+                });
 
-            if(matchedIds.length == 1) {
-                $('li[title="' + matchedIds[0].url + '"] li[idx="' + matchedIds[0].id + '"]').click();
+                $('.kmltree-selected').removeClass('kmltree-selected');
+                $.each(self.selectedFeatures, function(_, v) {
+                    $('li[title="' + v.url + '"] li[idx="' + v.id + '"]').addClass('kmltree-selected');
+                });
+
+                if(self.selectedFeatures.length > 1) {
+                    $('#selection-dialog').dialog('destroy').remove();
+                    var dlg = $(self.selectionDialog);
+                    var list = dlg.find('#selected-features-list')
+                    .html('');
+                    $.each(self.selectedFeatures, function(_, v) {
+                        var feat = self._kmls[v.url].data.features[v.id];
+                        var title = feat.properties.name;
+                        list.append('<li><div style="width: 20px; height: 20px; display: inline;" class="style-preview"></div><span>' + title + '</span></li>');
+                        var node = list.find('li div.style-preview').last()[0];
+                        self.renderPreview(feat, node);
+                    });
+                    dlg.dialog({
+                        close: function() {
+                            $('.kmltree-selected').removeClass('kmltree-selected');
+                            $(this).dialog('destroy').remove();
+                        }
+                    });
+                    dlg.find('.digitize-export').bind('click', function() {
+                        var data = {type: 'FeatureCollection', features: []};
+                        $.each(self.selectedFeatures, function(_, v) {
+                            var feat = self._kmls[v.url].data.features[v.id];
+                            data.features.push(feat);
+                            self.exportItem(data);
+                        });
+                        dlg.dialog('close');
+                    });
+                }
             }
         });
         self.element.bind('kml:loaded',function(event,obj){



More information about the Mapbender_commits mailing list