[Mapbender-commits] r8954 - in trunk/mapbender: http/css http/javascripts http/php http/plugins lib

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Jul 1 02:44:48 PDT 2014


Author: hwbllmnn
Date: 2014-07-01 02:44:48 -0700 (Tue, 01 Jul 2014)
New Revision: 8954

Modified:
   trunk/mapbender/http/css/digitize_new.css
   trunk/mapbender/http/javascripts/mod_changeEPSG.php
   trunk/mapbender/http/php/uploadKml.php
   trunk/mapbender/http/plugins/kmlTree.js
   trunk/mapbender/http/plugins/mb_digitize_widget.php
   trunk/mapbender/lib/mb.ui.displayKmlFeatures.js
Log:
added export dialog, fixed a couple of bugs


Modified: trunk/mapbender/http/css/digitize_new.css
===================================================================
--- trunk/mapbender/http/css/digitize_new.css	2014-07-01 09:42:20 UTC (rev 8953)
+++ trunk/mapbender/http/css/digitize_new.css	2014-07-01 09:44:48 UTC (rev 8954)
@@ -170,3 +170,43 @@
     height: 20px;
     display: inline;
 }
+
+.export-format-kml {
+    background-image: url('../img/kml_logo.png');
+    background-repeat: no-repeat;
+    background-position: center;
+    background-color: transparent;
+    width: 32px;
+    height: 50px;
+    line-height: 50px;
+    padding-left: 40px;
+    padding-top: 40px;
+}
+
+.export-format-gpx {
+    background-image: url('../img/gpx.png');
+    background-repeat: no-repeat;
+    background-position: center;
+    background-color: transparent;
+    width: 32px;
+    height: 50px;
+    line-height: 50px;
+    padding-left: 40px;
+    padding-top: 40px;
+}
+
+.export-format-geojson {
+    background-image: url('../img/json.png');
+    background-repeat: no-repeat;
+    background-position: center;
+    background-color: transparent;
+    width: 32px;
+    height: 50px;
+    line-height: 50px;
+    padding-left: 40px;
+    padding-top: 40px;
+}
+
+label > input[type="radio"] {
+    height: 50px;
+}

Modified: trunk/mapbender/http/javascripts/mod_changeEPSG.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_changeEPSG.php	2014-07-01 09:42:20 UTC (rev 8953)
+++ trunk/mapbender/http/javascripts/mod_changeEPSG.php	2014-07-01 09:44:48 UTC (rev 8954)
@@ -296,7 +296,7 @@
 				});
 			}
             var kml = $('#mapframe1').data('kml');
-            if(kml) {
+            if(kml && kml.render) {
                 kml.render();
             }
 		}

Modified: trunk/mapbender/http/php/uploadKml.php
===================================================================
--- trunk/mapbender/http/php/uploadKml.php	2014-07-01 09:42:20 UTC (rev 8953)
+++ trunk/mapbender/http/php/uploadKml.php	2014-07-01 09:44:48 UTC (rev 8954)
@@ -18,13 +18,12 @@
 
 require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
 require_once(dirname(__FILE__) . "/../classes/class_kml_ows.php");
-require_once(dirname(__FILE__) . "/../classes/class_connector.php");
 
 header("Content-Type: text/plain");
 
 $kml = new KML();
-$con = new connector();
-$content = $con->load($_FILES['kml']['tmp_name']);
+$content = file_get_contents($_FILES['kml']['tmp_name']);
+
 try {
     if(preg_match('/.kml$/', $_FILES['kml']['name'])) {
         header("Content-Type: text/plain");

Modified: trunk/mapbender/http/plugins/kmlTree.js
===================================================================
--- trunk/mapbender/http/plugins/kmlTree.js	2014-07-01 09:42:20 UTC (rev 8953)
+++ trunk/mapbender/http/plugins/kmlTree.js	2014-07-01 09:44:48 UTC (rev 8954)
@@ -109,6 +109,7 @@
                          + '<button class="add-kml"></button>'
                          + '</div>'
                          + '</div>';
+        $('#kml-load-tabs').remove();
         $(dlg).append(dlgcontent);
         $.ajax({
             type: 'get',
@@ -156,6 +157,7 @@
                 return;
             }
             kml.addLayer(title, {features: [], type: 'FeatureCollection'});
+            $(dlg).dialog('destroy');
         });
         var ifr = $('iframe[name="kml-upload-target"]')[0];
         var onloadfun = function() {

Modified: trunk/mapbender/http/plugins/mb_digitize_widget.php
===================================================================
--- trunk/mapbender/http/plugins/mb_digitize_widget.php	2014-07-01 09:42:20 UTC (rev 8953)
+++ trunk/mapbender/http/plugins/mb_digitize_widget.php	2014-07-01 09:44:48 UTC (rev 8954)
@@ -155,6 +155,15 @@
         '<li><div class="digitize-image digitize-close"></div>Close</li>' +
         '</ul>';
 
+    var exportHtml = '<div id="export-dialog" title="Export my features">'
+                     + '<form>'
+                     + '<label class="export-format-kml"><input type="radio" name="export-format" value="kml" checked="checked"></input></label>'
+                     + '<label class="export-format-gpx"><input type="radio" name="export-format" value="gpx"></input></label>'
+                     + '<label class="export-format-geojson"><input type="radio" name="export-format" value="geojson"></input></label>'
+                     + '<div class="digitize-image digitize-export" style="float: right;"></div>'
+                     + '</form>'
+                     + '</div>';
+
     var digitizeDialog,
         editDialog,
         attributesDialog,
@@ -267,6 +276,18 @@
         });
     };
 
+    var exportItem = function(data) {
+        var dlg = $(exportHtml).dialog();
+        $(dlg).find('.digitize-export').bind('click', function() {
+            var fmt = $(dlg).find('input:checked').val();
+            $(dlg).dialog('destroy');
+            if(fmt === 'kml') {
+                var kml = tokml(data, {simplestyle: true});
+                window.open('data:application/xml,' + encodeURIComponent(kml));
+            }
+        });
+    };
+
     var editStyle = function($link, menu) {
         var classPrefix = icons.preferences.fontPref.prefix,
             iconList = [],
@@ -406,8 +427,7 @@
             var url = $link.parent().parent().attr('title');
             var idx = $link.attr('idx');
             var data = kml._kmls[url];
-            kml = tokml(data.data.features[idx], {simplestyle: true});
-            window.open('data:application/xml,' + encodeURIComponent(kml));
+            exportItem(data.data.features[idx]);
             menu.menu('destroy').remove();
         });
         menu.children('li:has(.digitize-remove)').bind('click', function() {
@@ -552,8 +572,7 @@
             var kml = $('#mapframe1').data('kml');
             var url = $link.parent().attr('title');
             var data = kml._kmls[url];
-            kml = tokml(data.data, {simplestyle: true});
-            window.open('data:application/xml,' + encodeURIComponent(kml));
+            exportItem(data.data);
             menu.menu('destroy').remove();
         });
         menu.children('li:has(.digitize-add,.digitize-pencil)').bind('click', function() {

Modified: trunk/mapbender/lib/mb.ui.displayKmlFeatures.js
===================================================================
--- trunk/mapbender/lib/mb.ui.displayKmlFeatures.js	2014-07-01 09:42:20 UTC (rev 8953)
+++ trunk/mapbender/lib/mb.ui.displayKmlFeatures.js	2014-07-01 09:44:48 UTC (rev 8954)
@@ -46,6 +46,8 @@
     cache: {},
     kmlOrder: [],
     _popup : null,
+    creatingPhase: true,
+
     _create: function(){
         var self = this, o = this.options;
         this.element.mapbender().events.afterMapRequest.register(function () {
@@ -110,6 +112,7 @@
                 self.element.trigger('kml:loaded',kmls[this.kmlOrder[k]]);
             }
         }
+        this.creatingPhase = false;
         this.render();
     },
 
@@ -248,6 +251,10 @@
     },
 
     addLayer: function(url, data) {
+        if($.inArray(url, this.kmlOrder) !== -1) {
+            alert('Not adding ' + url + ', a layer with that name is already loaded.');
+            return;
+        }
         this.kmlOrder.push(url);
         this._kmls[url] = {type:"geojson",data:data,url:url,display: true};
         this.zoomToLayer(url);
@@ -544,6 +551,9 @@
     },
 
     render: function() {
+        if(this.creatingPhase) {
+            return;
+        }
         var target = $('#kml-rendering-pane');
         var map = $('#mapframe1').mapbender();
         this.targetProj = new Proj4js.Proj(map.getSrs());
@@ -564,6 +574,7 @@
                 if(!self.cache[url]) {
                     self.cache[url] = {};
                 }
+
                 feats = self.cache[url][map.getSrs()];
                 if(!feats) {
                     $.each(item.data.features, function(_, v) {



More information about the Mapbender_commits mailing list