[Mapbender-commits] r8841 - in trunk/mapbender: http/plugins lib
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Mon May 12 03:01:08 PDT 2014
Author: hwbllmnn
Date: 2014-05-12 03:01:08 -0700 (Mon, 12 May 2014)
New Revision: 8841
Modified:
trunk/mapbender/http/plugins/kmlTree.js
trunk/mapbender/lib/mb.ui.displayKmlFeatures.js
Log:
added switching visibility of single features
Modified: trunk/mapbender/http/plugins/kmlTree.js
===================================================================
--- trunk/mapbender/http/plugins/kmlTree.js 2014-05-12 09:41:39 UTC (rev 8840)
+++ trunk/mapbender/http/plugins/kmlTree.js 2014-05-12 10:01:08 UTC (rev 8841)
@@ -91,9 +91,15 @@
$featureList = $("<ul />");
$kmlEntry.append($featureList);
for(var i = 0;i < obj.data.features.length;i++){
+ var multi = obj.data.features[i].geometry.type.match(/^Multi/i);
+ var toggle = '';
+ if(multi) {
+ toggle = '<button class="toggle" name="toggle" value="toggle"></button>';
+ }
title = obj.data.features[i].properties.name;
abbrevTitle = title.length < 20 ? title : title.substr(0,17) + "...";
- $feature = $('<li idx="' + i + '" title="'+ title +'"><button class="digitize-menu-arrow"></button><a href="#" >'+ abbrevTitle + '</a></li>');
+ var displ = obj.data.features[i].display === true || obj.data.features[i].display === undefined;
+ $feature = $('<li idx="' + i + '" title="'+ title +'"><button class="digitize-menu-arrow"></button>' + toggle + '<input type="checkbox" ' + (displ ? 'checked="checked"' : '') + '/><a href="#" >'+ abbrevTitle + '</a></li>');
$featureList.append($feature);
title = obj.data.features[i].properties.name;
$feature.bind('click', function() {
@@ -192,10 +198,21 @@
});
$("*:checkbox",$kmlEntry).bind('click', function(){
- if($(this).attr('checked')){
- o.$target.kml('show',obj.url);
- }else{
- o.$target.kml('hide',obj.url);
+ var idx = $(this).parent().attr('idx');
+
+ if(idx === undefined) {
+ if($(this).attr('checked')){
+ o.$target.kml('show',obj.url);
+ }else{
+ o.$target.kml('hide',obj.url);
+ }
+ } else {
+ var kml = $('#mapframe1').data('kml');
+ if($(this).attr('checked')) {
+ kml.showFeature(obj.url, idx);
+ } else {
+ kml.hideFeature(obj.url, idx);
+ }
}
});
@@ -210,12 +227,6 @@
}
});
- $("button.remove",$kmlEntry).bind('click', function(){
- o.$target.kml('remove',obj.url);
- $(this).parent().remove();
- });
-
-
});
};
Modified: trunk/mapbender/lib/mb.ui.displayKmlFeatures.js
===================================================================
--- trunk/mapbender/lib/mb.ui.displayKmlFeatures.js 2014-05-12 09:41:39 UTC (rev 8840)
+++ trunk/mapbender/lib/mb.ui.displayKmlFeatures.js 2014-05-12 10:01:08 UTC (rev 8841)
@@ -224,6 +224,16 @@
map.setMapRequest();
},
+ showFeature: function(url, idx) {
+ this._kmls[url].highlightArray[idx].paint();
+ this._kmls[url].data.features[idx].display = true;
+ },
+
+ hideFeature: function(url, idx) {
+ this._kmls[url].highlightArray[idx].hide();
+ this._kmls[url].data.features[idx].display = false;
+ },
+
addGeometry: function(pts) {
var $map = $(this.element).mapbender();
var self = this;
@@ -445,7 +455,9 @@
}
if(mapitem.display){
for(var j in mapitem.highlightArray){
- mapitem.highlightArray[j].paint();
+ if(mapitem.data.features[j].display !== false) {
+ mapitem.highlightArray[j].paint();
+ }
}
}else{
for(var j in mapitem.highlightArray){
@@ -455,7 +467,9 @@
self.element.mapbender().events.afterMapRequest.register(function () {
if(mapitem.display){
for(var i in mapitem.highlightArray){
- mapitem.highlightArray[i].paint();
+ if(mapitem.data.features[i].display !== false) {
+ mapitem.highlightArray[i].paint();
+ }
}
}else{
for(var i in mapitem.highlightArray){
More information about the Mapbender_commits
mailing list