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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Jul 1 00:41:39 PDT 2014


Author: hwbllmnn
Date: 2014-07-01 00:41:39 -0700 (Tue, 01 Jul 2014)
New Revision: 8952

Modified:
   trunk/mapbender/http/css/kmltree.css
   trunk/mapbender/http/plugins/kmlTree.js
   trunk/mapbender/lib/mb.ui.displayKmlFeatures.js
Log:
added new tab to kml open dialog


Modified: trunk/mapbender/http/css/kmltree.css
===================================================================
--- trunk/mapbender/http/css/kmltree.css	2014-06-30 13:34:37 UTC (rev 8951)
+++ trunk/mapbender/http/css/kmltree.css	2014-07-01 07:41:39 UTC (rev 8952)
@@ -166,3 +166,13 @@
 a.icon-remote {
     background-image: url('../img/up-ilink.png');
 }
+
+a.icon-new {
+    background-image: url('../img/add.png');
+}
+
+#kml-new button.add-kml {
+    background-image:  url("../img/add.png");
+    background-repeat: no-repeat;
+    background-position: 50% 50%;
+}

Modified: trunk/mapbender/http/plugins/kmlTree.js
===================================================================
--- trunk/mapbender/http/plugins/kmlTree.js	2014-06-30 13:34:37 UTC (rev 8951)
+++ trunk/mapbender/http/plugins/kmlTree.js	2014-07-01 07:41:39 UTC (rev 8952)
@@ -79,13 +79,15 @@
             width: 450,
             height: 420,
             close: function() {
+                $('#kml-load-tabs').tabs('destroy');
                 $(this).html('').dialog('destroy');
             }
         });
         var dlgcontent = '<div id="kml-load-tabs">'
                          + '<ul><li><a class="icon icon-wmc" href="#kml-from-wmc">Stored data</a></li>'
                          + '<li><a class="icon icon-local" href="#kml-from-upload">Upload</a></li>'
-                         + '<li><a class="icon icon-remote" href="#kml-from-url">External source</a></li></ul>'
+                         + '<li><a class="icon icon-remote" href="#kml-from-url">External source</a></li>'
+                         + '<li><a class="icon icon-new" href="#kml-new">New</a></li></ul>'
                          + '<div id="kml-from-wmc">wmc</div>'
                          + '<div id="kml-from-upload">'
                          + '<iframe name="kml-upload-target" style="width: 0; height: 0; border: 0px;"></iframe>'
@@ -102,6 +104,10 @@
                          + 'Only KML, geoJSON and GPX files are supported. The files will be validated before they'
                          + ' are loaded into the mapviewer.'
                          + '</div>'
+                         + '<div id="kml-new">'
+                         + '<label>Title: <input type="text" name="kml-new-title"></input></label>'
+                         + '<button class="add-kml"></button>'
+                         + '</div>'
                          + '</div>';
         $(dlg).append(dlgcontent);
         $.ajax({
@@ -143,6 +149,14 @@
             $('#mapframe1').kml({ url: $('#kml-load-tabs').find('.kmlurl').val()});
             $(dlg).dialog('destroy');
         });
+        $('#kml-load-tabs').find('button.add-kml').bind('click', function() {
+            var kml = $('#mapframe1').data('kml');
+            var title = $('#kml-load-tabs input[name="kml-new-title"]').val();
+            if(title == '') {
+                return;
+            }
+            kml.addLayer(title, {features: [], type: 'FeatureCollection'});
+        });
         var ifr = $('iframe[name="kml-upload-target"]')[0];
         var onloadfun = function() {
             ifr.onload = null;

Modified: trunk/mapbender/lib/mb.ui.displayKmlFeatures.js
===================================================================
--- trunk/mapbender/lib/mb.ui.displayKmlFeatures.js	2014-06-30 13:34:37 UTC (rev 8951)
+++ trunk/mapbender/lib/mb.ui.displayKmlFeatures.js	2014-07-01 07:41:39 UTC (rev 8952)
@@ -138,6 +138,9 @@
 
     zoomToLayer: function(url) {
         var bbox = this.getLayerBbox(url);
+        if(!bbox) {
+            return;
+        }
         var map = $('#mapframe1').mapbender();
 
         var min = Proj4js.transform(this.wgs84, this.targetProj, {x: bbox[0], y: bbox[1]});
@@ -298,6 +301,9 @@
     getLayerBbox: function(url) {
         var self = this;
         var itm = this._kmls[url];
+        if(itm.data.features.length == 0) {
+            return false;
+        }
         var bbox = this.getBbox(itm.data.features[0]);
         $.each(itm.data.features, function(_, v) {
             var newbox = self.getBbox(v);



More information about the Mapbender_commits mailing list