OpenLayers.Control.LoadingPanel=OpenLayers.Class(OpenLayers.Control,{counter:0,maximized:false,visible:true,initialize:function(options){OpenLayers.Control.prototype.initialize.apply(this,[options]);},setVisible:function(visible){this.visible=visible;if(visible){OpenLayers.Element.show(this.div);}else{OpenLayers.Element.hide(this.div);}},getVisible:function(){return this.visible;},hide:function(){this.setVisible(false);},show:function(){this.setVisible(true);},toggle:function(){this.setVisible(!this.getVisible());},addLayer:function(evt){if(evt.layer){evt.layer.events.register('loadstart',this,this.increaseCounter);evt.layer.events.register('loadend',this,this.decreaseCounter);}},setMap:function(map){OpenLayers.Control.prototype.setMap.apply(this,arguments);this.map.events.register('preaddlayer',this,this.addLayer);for(var i=0;i<this.map.layers.length;i++){var layer=this.map.layers[i];layer.events.register('loadstart',this,this.increaseCounter);layer.events.register('loadend',this,this.decreaseCounter);}},increaseCounter:function(){this.counter++;if(this.counter>0){if(!this.maximized&&this.visible){this.maximizeControl();}}},decreaseCounter:function(){if(this.counter>0){this.counter--;}if(this.counter==0){if(this.maximized&&this.visible){this.minimizeControl();}}},draw:function(){OpenLayers.Control.prototype.draw.apply(this,arguments);return this.div;},minimizeControl:function(evt){this.div.style.display="none";this.maximized=false;if(evt!=null){OpenLayers.Event.stop(evt);}},maximizeControl:function(evt){this.div.style.display="block";this.maximized=true;if(evt!=null){OpenLayers.Event.stop(evt);}},destroy:function(){if(this.map){this.map.events.unregister('preaddlayer',this,this.addLayer);if(this.map.layers){for(var i=0;i<this.map.layers.length;i++){var layer=this.map.layers[i];layer.events.unregister('loadstart',this,this.increaseCounter);layer.events.unregister('loadend',this,this.decreaseCounter);}}}OpenLayers.Control.prototype.destroy.apply(this,arguments);},CLASS_NAME:"OpenLayers.Control.LoadingPanel"});;var map;var projectlayer=new OpenLayers.Layer.Vector("Lade Inhalte");var loadingPanel=new OpenLayers.Control.LoadingPanel();var control=new OpenLayers.Control.SelectFeature(projectlayer);function set_up_map_defaults(lng,lat,zoom){zoom=zoom||6;map=new OpenLayers.Map('map');map.addControl(new OpenLayers.Control.LayerSwitcher());map.addControl(loadingPanel);var mapnik=new OpenLayers.Layer.OSM();var ghyb=new OpenLayers.Layer.Google("Hybrid (Google)",{type:google.maps.MapTypeId.HYBRID});var gmap=new OpenLayers.Layer.Google("Karte (Google)",{numZoomLevels:20});var gterr=new OpenLayers.Layer.Google("Gelände (Google)",{type:google.maps.MapTypeId.TERRAIN,numZoomLevels:22});var gsat=new OpenLayers.Layer.Google("Satellit (Google)",{type:google.maps.MapTypeId.SATELLITE,numZoomLevels:22});map.addLayers([gterr,gmap,gsat,ghyb,mapnik]);map.setCenter(new OpenLayers.LonLat(lng,lat).transform(new OpenLayers.Projection("EPSG:4326"),map.getProjectionObject()),zoom);}function set_up_kategorie_filter(defaultkategorie){jQuery(document).ready(function($){var kategoriemenu='<div class="span-2"><strong>FILTER</strong></div>'+'<div class="span-13 last">'+'<a class="kategoriefilter" id="kategorie-alle" href="#" onclick="return false;">Alle</a> | '+'<a class="kategoriefilter" id="kategorie-abgeordnete" href="#" onclick="return false;">Abgeordnete</a> | '+'<a class="kategoriefilter" id="kategorie-buergerhaushalt" href="#" onclick="return false;">Bürgerhaushalt</a> | '+'<a class="kategoriefilter" id="kategorie-buergerbegehren" href="#" onclick="return false;">Bürgerbegehren</a> | '+'<a class="kategoriefilter" id="kategorie-buergeranliegen" href="#" onclick="return false;">Bürgeranliegen</a> | '+'</div>'+'<div class="prepend-2 span-13 last">'+'<a class="kategoriefilter" id="kategorie-buergerinitiative" href="#" onclick="return false;">Bürgerinitiative</a> | '+'<a class="kategoriefilter" id="kategorie-demonstration" href="#" onclick="return false;">Demonstration</a> | '+'<a class="kategoriefilter" id="kategorie-diskussion" href="#" onclick="return false;">Diskussion</a> | '+'<a class="kategoriefilter" id="kategorie-petition" href="#" onclick="return false;">Petition</a> | '+'<a class="kategoriefilter" id="kategorie-volksbegehren" href="#" onclick="return false;">Volksbegehren</a> | '+'<a class="kategoriefilter" id="kategorie-wahlen" href="#" onclick="return false;">Wahlen</a>'+'</div>';$("div#kategoriefilter").html(kategoriemenu);$("a.kategoriefilter").each(function(){kategorie=this.id.replace("kategorie-","");kategorie=kategorie.replace('ue','ü');kategoriecolor=kategorie_color_lookup[kategorie.slice(0,1).toUpperCase()+kategorie.slice(1)].fillColor;$(this).css('color',kategoriecolor);$(this).click(function(){changekategorie=this.id.replace("kategorie-","/kategorie/");changekategorie=changekategorie.replace("/kategorie/alle","");mapSource=changekategorie;$("a.kategoriefilter").each(function(){$(this).removeClass("filter-selected");});$(this).addClass("filter-selected");$('.statusfilter.filter-selected').click();});});$('a[id="'+defaultkategorie+'"]').click();});}function set_up_status_filter(defaultstatus){jQuery(document).ready(function($){var statusmenu='<div class="span-2"><strong>STATUS</strong></div>'+'<a class="statusfilter" id="status-laufend" href="#" onclick="return false;">Laufend</a> | '+'<a class="statusfilter" id="status-abgeschlossen" href="#" onclick="return false;">Abgeschlossen</a> '+'| <a class="statusfilter" id="status-alle" href="#" onclick="return false;">Alle</a>';$("div#statusfilter").html(statusmenu);$("a.statusfilter").each(function(){$(this).click(function(){changestatus=this.id.replace("status-","");currentURL=mapBaseURL+mapSource+feedURL+"status="+changestatus;switchLayer(currentURL);$("a.statusfilter").each(function(){$(this).removeClass("filter-selected");});$(this).addClass("filter-selected");});});$('a[id="'+defaultstatus+'"]').click();});}var kategorie_color_lookup={"Alle":{fillColor:"#D84815"},"Abgeordnete":{fillColor:"#166484"},"Bürgeranliegen":{fillColor:"#aba105"},"Bürgerbegehren":{fillColor:"#9f0404"},"Bürgerhaushalt":{fillColor:"#00a2e6"},"Bürgerinitiative":{fillColor:"green"},"Demonstration":{fillColor:"#e72b00"},"Diskussion":{fillColor:"#a03c6d"},"Petition":{fillColor:"#5a4641"},"Volksentscheid":{fillColor:"black"},"Wahlen":{fillColor:"green"},"Volksbegehren":{fillColor:"black"}};var selectStyle=new OpenLayers.Style({strokeWidth:4});var defaultStyle=new OpenLayers.Style({fillOpacity:0.7,label:"${labeltext}",fontWeight:"bold",fontColor:"black",pointRadius:"${radius}",strokeWidth:"${width}",strokeDashstyle:"${dashstyle}",strokeColor:"black"},{context:{width:function(feature){return(feature.cluster)?2:0.6;},radius:function(feature){var pix=5;if(feature.cluster){pix=Math.max(feature.attributes.count,pix)+5;pix=Math.min(20,pix)}return pix;},dashstyle:function(feature){if(feature.cluster){return"longdash";}else{return"solid";}},labeltext:function(feature){if(feature.cluster){return feature.attributes.count;}else{return"";}}}});var styleMap=new OpenLayers.StyleMap({'default':defaultStyle,'select':selectStyle});styleMap.addUniqueValueRules("default","type",kategorie_color_lookup);elserule=new OpenLayers.Rule({elseFilter:true,symbolizer:{fillColor:"#D84815"}});defaultStyle.addRules([elserule]);var ruleArea=new OpenLayers.Rule({filter:new OpenLayers.Filter.Comparison({type:OpenLayers.Filter.Comparison.LESS_THAN,property:"zuordnung",value:6}),symbolizer:{pointRadius:8,fillOpacity:0.7,strokeDashstyle:"dot"}});var rulePreciseLoc=new OpenLayers.Rule({filter:new OpenLayers.Filter.Comparison({type:OpenLayers.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO,property:"zuordnung",value:6}),symbolizer:{pointRadius:5,fillOpacity:0.7,strokeDashstyle:"solid"}});defaultStyle.addRules([ruleArea,rulePreciseLoc]);function onPopupClose(evt){control.unselect(this.feature);}function onFeatureSelect(evt){feature=evt.feature;if(feature.cluster){var the_content="<h3 class='mapMarkerTitle'>"+feature.attributes.count+" verschiedene Projekte</h3>";for(index in feature.cluster){the_content+='<a href="'+feature.cluster[index].attributes.link+'">'+feature.cluster[index].attributes.type+" in ";if(feature.cluster[index].attributes.zuordnung=="3"){the_content+='Kreis '+feature.cluster[index].attributes.kreis;}else if(feature.cluster[index].attributes.zuordnung=="3.5"){the_content+='Amt '+feature.cluster[index].attributes.amt;}else if(feature.cluster[index].attributes.zuordnung=="2"){the_content+=feature.cluster[index].attributes.bundesland;}else if(feature.cluster[index].attributes.zuordnung=="1"){the_content+='Deutschland';}else{the_content+=feature.cluster[index].attributes.ort;}the_content+=":\t"+feature.cluster[index].attributes.title+"</a><br />";}}else{var publicationdate=new Date(feature.attributes.pubDate);var the_content;if(feature.attributes.zuordnung=="3"){the_content='Kreis '+feature.attributes.kreis+'<br />';}else if(feature.attributes.zuordnung=="3.5"){the_content='Amt '+feature.attributes.amt+'<br />';}else if(feature.attributes.zuordnung=="2"){the_content='Bundesland '+feature.attributes.bundesland+'<br />';}else if(feature.attributes.zuordnung=="1"){the_content='Bundesrepublik Deutschland<br />';}else{the_content=feature.attributes.ort+'<br />';}the_content=the_content+'<h3 class="mapMarkerTitle">'+feature.attributes.title+'</h3>'+feature.attributes.description.replace(/<[^>]*>?/g,'').substr(0,200)+' ...<br><a href="'+feature.attributes.link+'">weitere Details</a>'+'<hr />'+'Kategorie: '+feature.attributes.type+' | Status: '+feature.attributes.status+' | eingetragen: '+publicationdate.toDateString();}popup=new OpenLayers.Popup.FramedCloud("featurePopup",feature.geometry.getBounds().getCenterLonLat(),new OpenLayers.Size(50,50),the_content,null,true,onPopupClose);feature.popup=popup;popup.feature=feature;map.addPopup(popup);}function onFeatureSelectOLD(evt){feature=evt.feature;var publicationdate=new Date(feature.attributes.pubDate);popup=new OpenLayers.Popup.FramedCloud("featurePopup",feature.geometry.getBounds().getCenterLonLat(),new OpenLayers.Size(50,50),"<h3 class='mapMarkerTitle'>"+feature.attributes.title+"</h3>"+feature.attributes.description.substr(0,200)+" ...<br><a href='"+feature.attributes.link+"'>weitere Details</a>"+"<hr />"+"Kategorie: "+feature.attributes.type+" | Status: "+feature.attributes.status+" | eingetragen: "+publicationdate.toDateString(),null,true,onPopupClose);feature.popup=popup;popup.feature=feature;map.addPopup(popup);}function onFeatureUnselect(evt){feature=evt.feature;if(feature.popup){popup.feature=null;map.removePopup(feature.popup);feature.popup.destroy();feature.popup=null;}}function switchLayer(sourceurl){while(map.popups.length){map.removePopup(map.popups[0]);}control.destroy();projectlayer.destroy();var start=0;projectlayer=new OpenLayers.Layer.Vector("Beteiligungsprojekte",{styleMap:styleMap,strategies:[new OpenLayers.Strategy.Fixed(),new OpenLayers.Strategy.Cluster({distance:20,threshold:2})],protocol:new OpenLayers.Protocol.HTTP({url:sourceurl,format:new OpenLayers.Format.GeoRSS({createFeatureFromItem:function(item){var feature=OpenLayers.Format.GeoRSS.prototype.createFeatureFromItem.apply(this,arguments);feature.attributes.status=this.getChildValue(item,"http://www.meine-demokratie.de","status","(keine Statusinformation gefunden)");feature.attributes.ort=this.getChildValue(item,"http://www.meine-demokratie.de","ort","(keine Ortsinformation gefunden)");feature.attributes.kreis=this.getChildValue(item,"http://www.meine-demokratie.de","kreis","(keine Kreisinformation gefunden)");feature.attributes.bundesland=this.getChildValue(item,"http://www.meine-demokratie.de","bundesland","(keine Bundeslandinformation gefunden)");feature.attributes.amt=this.getChildValue(item,"http://www.meine-demokratie.de","amt","(keine Amtsinformationen gefunden)");feature.attributes.type=this.getChildValue(item,"http://www.georss.org/georss","featureTypeTag","(Kategorie unklar)");feature.attributes.pubDate=this.getChildValue(item,"*","pubDate","(Datum unklar)");feature.attributes.zuordnung=this.getElementsByTagNameNS(item,"http://www.meine-demokratie.de","zuordnung")[0].getAttribute("value");return feature;}})})});projectlayer.events.on({'featureselected':onFeatureSelect,'featureunselected':onFeatureUnselect});map.addLayer(projectlayer);control=new OpenLayers.Control.SelectFeature(projectlayer);map.addControl(control);control.activate();}
