[Mapbender-commits] r8823 - in trunk/mapbender: http/plugins lib
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Wed May 7 05:02:54 PDT 2014
Author: hwbllmnn
Date: 2014-05-07 05:02:54 -0700 (Wed, 07 May 2014)
New Revision: 8823
Modified:
trunk/mapbender/http/plugins/kmlTree.js
trunk/mapbender/lib/mb.ui.displayKmlFeatures.js
Log:
added reordering of kml features via drag & drop
Modified: trunk/mapbender/http/plugins/kmlTree.js
===================================================================
--- trunk/mapbender/http/plugins/kmlTree.js 2014-05-07 11:22:49 UTC (rev 8822)
+++ trunk/mapbender/http/plugins/kmlTree.js 2014-05-07 12:02:54 UTC (rev 8823)
@@ -95,7 +95,7 @@
title = obj.data.features[i].properties.name;
abbrevTitle = title.length < 20 ? title : title.substr(0,17) + "...";
- $feature = $('<li title="'+ title +'"><a href="#" >'+ abbrevTitle + '</a></li>');
+ $feature = $('<li idx="' + i + '" title="'+ title +'"><a href="#" >'+ abbrevTitle + '</a></li>');
$featureList.append($feature);
title = obj.data.features[i].properties.name;
$feature.bind('click',(function(jsonFeature){return function(){
@@ -176,16 +176,19 @@
}
});
- // $('#kmlTree > li > ul > li > ul').sortable({
- // update: function() {
- // var kml = $('#mapframe1').data('kml');
- // var urls = [];
- // $(this).children('li[title]').each(function(k, v) {
- // urls.push($(this).attr('title'));
- // });
- // kml.setOrder(urls);
- // }
- // });
+ $('#kmlTree > li > ul > li > ul').sortable({
+ update: function(evt, data) {
+ var kml = $('#mapframe1').data('kml');
+ var url = $(this).parent().attr('title');
+ var ids = [];
+ var i = 0;
+ $.each($(this).children(), function(k, v) {
+ ids.push($(v).attr('idx'));
+ $(v).attr('idx', i++);
+ });
+ kml.reorderFeatures(url, ids);
+ }
+ });
$("*:checkbox",$kmlEntry).bind('click', function(){
if($(this).attr('checked')){
Modified: trunk/mapbender/lib/mb.ui.displayKmlFeatures.js
===================================================================
--- trunk/mapbender/lib/mb.ui.displayKmlFeatures.js 2014-05-07 11:22:49 UTC (rev 8822)
+++ trunk/mapbender/lib/mb.ui.displayKmlFeatures.js 2014-05-07 12:02:54 UTC (rev 8823)
@@ -332,6 +332,16 @@
this.reload();
},
+ reorderFeatures: function(url, ids) {
+ var itm = this._kmls[url];
+ var list = [];
+ $.each(ids, function(k, v) {
+ list.push(itm.data.features[v]);
+ });
+ itm.data.features = list;
+ this._convertFromJson(itm);
+ },
+
show : function(url){
this._kmls[url].display = true;
var $map = $(this.element).mapbender();
More information about the Mapbender_commits
mailing list