[Mapbender-commits] r8899 - trunk/mapbender/lib

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu May 22 03:08:12 PDT 2014


Author: hwbllmnn
Date: 2014-05-22 03:08:12 -0700 (Thu, 22 May 2014)
New Revision: 8899

Modified:
   trunk/mapbender/lib/mb.ui.displayKmlFeatures.js
Log:
fixed ordering issue of kml layers


Modified: trunk/mapbender/lib/mb.ui.displayKmlFeatures.js
===================================================================
--- trunk/mapbender/lib/mb.ui.displayKmlFeatures.js	2014-05-22 08:28:28 UTC (rev 8898)
+++ trunk/mapbender/lib/mb.ui.displayKmlFeatures.js	2014-05-22 10:08:12 UTC (rev 8899)
@@ -51,6 +51,7 @@
         this.element.mapbender().events.afterMapRequest.register(function () {
             self.render();
         });
+
         this.element.bind('click', function(e) {
             var map = self.element.mapbender();
             var pos = map.getMousePosition(e);
@@ -75,7 +76,7 @@
                         matchedIds.push(k);
                     }
                 } else {
-                    var box = self.getBbox(itm.data.features[k]);
+                    var box = self.getBbox(v);
                     if(box[0] < wgspt.x && box[2] > wgspt.x && box[1] < wgspt.y && box[3] > wgspt.y) {
                         matched.push(v);
                         matchedIds.push(k);
@@ -96,25 +97,25 @@
             alert(message);
         });
 
-        var kmls = mb_getWmcExtensionData('KMLS');
+        var kmls = mb_getWmcExtensionData('KMLORDER');
         if(kmls) {
+            this.kmlOrder = JSON.parse(kmls);
+        }
+        kmls = mb_getWmcExtensionData('KMLS');
+        if(kmls) {
             kmls = JSON.parse(kmls);
             this._kmls = kmls;
-            for(var k in kmls) {
-                kmls[k].loadedOnStartup = true;
-                self.element.trigger('kml:loaded',kmls[k]);
+            for(var k in this.kmlOrder) {
+                kmls[this.kmlOrder[k]].loadedOnStartup = true;
+                self.element.trigger('kml:loaded',kmls[this.kmlOrder[k]]);
             }
         }
-        kmls = mb_getWmcExtensionData('KMLORDER');
-        if(kmls) {
-            this.kmlOrder = JSON.parse(kmls);
-        }
         this.render();
     },
 
     _init: function(){
         var self = this, o = this.options;
-        this._popup = $('<div></div>').dialog({autoOpen : false, height: 500, width: 500});
+        this._popup = $('<div></div>').dialog({autoOpen: false, height: 500, width: 500});
         if(o.url){
             self._load(o.url);
         }
@@ -274,7 +275,9 @@
     },
 
     remove: function(url){
-        delete(this._kmls[url]);
+        delete this._kmls[url];
+        this.kmlOrder.splice(this.kmlOrder.indexOf(url), 1);
+        delete this.cache[url];
         var $map = $(this.element).mapbender();
         var extent = $map.getExtentInfos();
         $map.calculateExtent(extent);
@@ -321,6 +324,8 @@
             coords = feature.geometry.coordinates;
             minx = coords[0][0][0];
             miny = coords[0][0][1];
+            maxx = minx;
+            maxy = miny;
             $.each(coords, function(_, v) {
                 $.each(v, function(_, v2) {
                     minx = Math.min(minx, v2[0]);
@@ -472,6 +477,9 @@
         var canvas = Raphael(target, map.getWidth(), map.getHeight());
         $.each(this.kmlOrder, function(_, url) {
             var item = self._kmls[url];
+            if(!item) {
+                return;
+            }
             var feats = item.data.features;
 
             if(!map.getSrs().match(/:4326/)) {



More information about the Mapbender_commits mailing list