OpenLayers.DOTS_PER_INCH=96;OpenLayers.IMAGE_RELOAD_ATTEMPTS=1;OpenLayers.Util.onImageLoadErrorColor="transparent";OpenLayers.Feature.prototype.popupClass=OpenLayers.Popup.FramedCloud;OpenLayers.Popup.FramedCloud.prototype.autoSize=false;OpenLayers.Events.prototype.includeXY=true;OpenLayers.Util.onImageLoadError=function(){this.src="http://www.conselldemallorca.net/sit/libs/openlayers28/img/blank.gif";this.style.display="";};OpenLayers.Map.prototype.addPopup=function(popup,exclusive){if(exclusive){for(var i=this.popups.length-1;i>=0;--i){this.removePopup(this.popups[i]);}}
popup.map=this;this.popups.push(popup);var popupDiv=popup.draw();if(popupDiv){popupDiv.style.zIndex=this.Z_INDEX_BASE['Popup']+this.popups.length;this.layerContainerDiv.appendChild(popupDiv);}
this.events.triggerEvent("popupopen");};var listFeatures_geometry=new Array();function cimSenderismeMap(){this.map=null;this.printScale=new Array(800000,400000,200000,100000,50000,25000,12500,5000,3000);}
cimSenderismeMap.prototype.init=function(){this.lat=4381000;this.lon=487000;var popupWidth0=300;var popupHeight0=350;var popupWidth1=250;var popupHeight1=150;this.zoom=0;OpenLayers.loadURL("gml/senderisme.gml","",null,parseSenderismeData);this.options={'controls':[],maxExtent:new OpenLayers.Bounds(406151.054102116864,4254301.845737015808,622898.154262984192,4471048.945897883136),restrictedExtent:new OpenLayers.Bounds(406151.054102116864,4254301.845737015808,622898.154262984192,4471048.945897883136),maxResolution:211.667090000847,scales:[800000,400000,200000,100000,50000,25000,12500,6250,3125],tileOrigin:new OpenLayers.LonLat(-5120900,9998100),tileSize:new OpenLayers.Size(512,512),projection:'EPSG:25831',units:'m',allOverlays:true};this.map=new OpenLayers.Map(this.options);this.layerMapa=new OpenLayers.Layer.ArcGISCache("Mapa","http://www.conselldemallorca.net/mapcache/demo_base/MAPA",{layername:'_alllayers',type:'png',tileSize:new OpenLayers.Size(256,256),tileOrigin:new OpenLayers.LonLat(-5120900,9998100),transitionEffect:'resize','isBaseLayer':false,buffer:1});this.map.addLayer(this.layerMapa);this.layerOrto=new OpenLayers.Layer.ArcGISCache("Ortofoto 2008","http://www.conselldemallorca.net/mapcache/orto2008/Layers",{layername:'_alllayers',type:'jpg',tileSize:new OpenLayers.Size(256,256),tileOrigin:new OpenLayers.LonLat(-5120900,9998100),transitionEffect:'resize','isBaseLayer':false,'visibility':false,buffer:1});this.map.addLayer(this.layerOrto);this.layerBIC=new OpenLayers.Layer.ArcGISCache("BIC","http://www.conselldemallorca.net/mapcache/pedra_bics/Layers",{layername:'_alllayers',type:'png',tileSize:new OpenLayers.Size(256,256),tileOrigin:new OpenLayers.LonLat(-5120900,9998100),'isBaseLayer':false,'visibility':false,'opacity':0.6,buffer:1});this.map.addLayer(this.layerBIC);this.fpubliques=new OpenLayers.Layer.ArcGISCache("Finques públiques","http://www.conselldemallorca.net/mapcache/finques_publiques/Layers",{layername:'_alllayers',type:'png',tileSize:new OpenLayers.Size(256,256),tileOrigin:new OpenLayers.LonLat(-5120900,9998100),'isBaseLayer':false,'visibility':false,'opacity':0.6,buffer:1});this.map.addLayer(this.fpubliques);this.enp=new OpenLayers.Layer.ArcGISCache("Espais Naturals Protegits","http://www.conselldemallorca.net/mapcache/enp/Layers",{layername:'_alllayers',type:'png',tileSize:new OpenLayers.Size(256,256),tileOrigin:new OpenLayers.LonLat(-5120900,9998100),'isBaseLayer':false,'visibility':false,'opacity':0.5,buffer:1});this.map.addLayer(this.enp);this.xn2000=new OpenLayers.Layer.ArcGISCache("Xarxa Natura 2000","http://www.conselldemallorca.net/mapcache/XN2000/Layers",{layername:'_alllayers',type:'png',tileSize:new OpenLayers.Size(256,256),tileOrigin:new OpenLayers.LonLat(-5120900,9998100),'isBaseLayer':false,'visibility':false,'opacity':0.7,buffer:1});this.map.addLayer(this.xn2000);this.layerSenderisme=new OpenLayers.Layer.ArcGISCache("Senderisme","http://www.conselldemallorca.net/mapcache/WMSsenderisme/Senderisme",{layername:'_alllayers',type:'png',tileSize:new OpenLayers.Size(256,256),tileOrigin:new OpenLayers.LonLat(-5120900,9998100),'displayInLayerSwitcher':false,'isBaseLayer':false,'opacity':0.6,buffer:1});this.map.addLayer(this.layerSenderisme);this.layerSenderisme=new OpenLayers.Layer.ArcGISCache("Itineraris familiars","http://www.conselldemallorca.net/mapcache/senderisme_itinerari/Layers",{layername:'_alllayers',type:'png',tileOrigin:new OpenLayers.LonLat(-5120900,9998100),'displayInLayerSwitcher':false,'isBaseLayer':false,'visibility':false,'opacity':0.6,buffer:0});this.map.addLayer(this.layerSenderisme);var layer_style=OpenLayers.Util.extend({},OpenLayers.Feature.Vector.style['default']);layer_style.graphicOpacity=1;layer_style.strokeColor="#00FF00";layer_style.strokeWidth=5;this.selectLayer=new OpenLayers.Layer.Vector("Select layer",{'isBaseLayer':false,'isFixed':false,projection:'EPSG:25831',units:'m',style:layer_style});this.map.addLayer(this.selectLayer);var cimIcon=new OpenLayers.Icon("images/camera.png",new OpenLayers.Size(32,32));this.layerFotos=new OpenLayers.Layer.GeoRSS("Fotos","georss/fotos.xml",{useFeedTitle:false,popupSize:new OpenLayers.Size(popupWidth0,popupHeight0),'maxResolution':6.61459656252646,'visibility':false,'icon':cimIcon});this.map.addLayer(this.layerFotos);this.layerFotos.maxResolution=6.61459656252646;var cimIcon=new OpenLayers.Icon("images/green.png",new OpenLayers.Size(32,32));this.layerPatrimoni=new OpenLayers.Layer.GeoRSS("Patrimoni","georss/patrimoni_"+locText.language+".xml",{useFeedTitle:false,popupSize:new OpenLayers.Size(popupWidth0,popupHeight0),'maxResolution':6.61459656252646,'visibility':false,'icon':cimIcon});this.map.addLayer(this.layerPatrimoni);this.layerPatrimoni.maxResolution=6.61459656252646;var cimIcon=new OpenLayers.Icon("images/partly_cloudy.png",new OpenLayers.Size(32,32));this.layerMeteo=new OpenLayers.Layer.GeoRSS("Meteo","georss/meteo_"+locText.language+".xml",{useFeedTitle:false,popupSize:new OpenLayers.Size(popupWidth1,popupHeight1),'maxResolution':105.833545000423,'visibility':false,'icon':cimIcon});this.map.addLayer(this.layerMeteo);this.layerMeteo.maxResolution=105.833545000423;var cimIcon=new OpenLayers.Icon("images/info.png",new OpenLayers.Size(32,32));this.layerInfo=new OpenLayers.Layer.GeoRSS("Informació","georss/informacio_"+locText.language+".xml",{useFeedTitle:false,popupSize:new OpenLayers.Size(popupWidth1,popupHeight1),'maxResolution':3.30729828126323,'visibility':false,'icon':cimIcon});this.map.addLayer(this.layerInfo);this.layerInfo.maxResolution=3.30729828126323;var cimIcon=new OpenLayers.Icon("images/picnic.png",new OpenLayers.Size(32,32));this.layerRecrea=new OpenLayers.Layer.GeoRSS("Àrees recreatives","georss/areesrecreatives_"+locText.language+".xml",{useFeedTitle:false,popupSize:new OpenLayers.Size(popupWidth1,popupHeight1),'visibility':false,'icon':cimIcon});this.map.addLayer(this.layerRecrea);var cimIcon=new OpenLayers.Icon("images/hospitals.png",new OpenLayers.Size(32,32));this.layerSanitaris=new OpenLayers.Layer.GeoRSS("Sanitaris","georss/sanitaris_"+locText.language+".xml",{useFeedTitle:false,popupSize:new OpenLayers.Size(popupWidth1,popupHeight1),'maxResolution':3.30729828126323,'visibility':false,'icon':cimIcon});this.map.addLayer(this.layerSanitaris);this.layerSanitaris.maxResolution=3.30729828126323;var cimIcon=new OpenLayers.Icon("images/police.png",new OpenLayers.Size(32,32));this.layerPolicia=new OpenLayers.Layer.GeoRSS("Policia local","georss/policia_"+locText.language+".xml",{useFeedTitle:false,popupSize:new OpenLayers.Size(popupWidth1,popupHeight1),'maxResolution':3.30729828126323,'visibility':false,'icon':cimIcon});this.map.addLayer(this.layerPolicia);this.layerPolicia.maxResolution=3.30729828126323;var cimIcon=new OpenLayers.Icon("images/museus.png",new OpenLayers.Size(32,32));this.museus=new OpenLayers.Layer.GeoRSS("Museus","georss/museus_"+locText.language+".xml",{useFeedTitle:false,popupSize:new OpenLayers.Size(popupWidth1,popupHeight1),'maxResolution':3.30729828126323,'visibility':false,'icon':cimIcon});this.map.addLayer(this.museus);this.museus.maxResolution=3.30729828126323;var cimIcon=new OpenLayers.Icon("images/refugiextern.png",new OpenLayers.Size(32,32));this.layerRefugisExt=new OpenLayers.Layer.GeoRSS("Altres refugis","georss/refugisexterns_"+locText.language+".xml",{useFeedTitle:false,popupSize:new OpenLayers.Size(popupWidth1,popupHeight1),'visibility':false,'icon':cimIcon});this.map.addLayer(this.layerRefugisExt);var cimIcon=new OpenLayers.Icon("images/bus.png",new OpenLayers.Size(32,32));this.layerTransportBus=new OpenLayers.Layer.GeoRSS("Bus","georss/bus_"+locText.language+".xml",{useFeedTitle:false,popupSize:new OpenLayers.Size(popupWidth1,popupHeight1),'maxResolution':3.30729828126323,'visibility':false,'icon':cimIcon});this.map.addLayer(this.layerTransportBus);this.layerTransportBus.maxResolution=3.30729828126323;var cimIcon=new OpenLayers.Icon("images/rail.png",new OpenLayers.Size(32,32));this.layerTransportTren=new OpenLayers.Layer.GeoRSS("Tren","georss/tren_"+locText.language+".xml",{useFeedTitle:false,popupSize:new OpenLayers.Size(popupWidth1,popupHeight1),'maxResolution':3.30729828126323,'visibility':false,'icon':cimIcon});this.map.addLayer(this.layerTransportTren);this.layerTransportTren.maxResolution=3.30729828126323;var cimIcon=new OpenLayers.Icon("images/ferry.png",new OpenLayers.Size(32,32));this.layerTransportBarco=new OpenLayers.Layer.GeoRSS("Marítim","georss/maritim_"+locText.language+".xml",{useFeedTitle:false,popupSize:new OpenLayers.Size(popupWidth1,popupHeight1),'maxResolution':3.30729828126323,'visibility':false,'icon':cimIcon});this.map.addLayer(this.layerTransportBarco);this.layerTransportBarco.maxResolution=3.30729828126323;var cimIcon=new OpenLayers.Icon("images/homegardenbusiness.png",new OpenLayers.Size(32,32));this.layerRefugis=new OpenLayers.Layer.GeoRSS("Refugis","georss/refugis_"+locText.language+".xml",{useFeedTitle:false,popupSize:new OpenLayers.Size(popupWidth0,popupHeight0),'icon':cimIcon});this.map.addLayer(this.layerRefugis);var cimIcon=new OpenLayers.Icon("images/it_familiar.png",new OpenLayers.Size(20,32));this.layerItineraris=new OpenLayers.Layer.GeoRSS("Icon Itiniraris","georss/itineraris_"+locText.language+".xml",{useFeedTitle:false,popupSize:new OpenLayers.Size(popupWidth1,popupHeight1),'maxResolution':26.4583862501058,'visibility':false,'icon':cimIcon});this.map.addLayer(this.layerItineraris);this.layerItineraris.maxResolution=26.4583862501058;var cimIcon=new OpenLayers.Icon("images/hiker1.png",new OpenLayers.Size(20,32));this.layerRutes=new OpenLayers.Layer.GeoRSS("Rutes","georss/rutes_"+locText.language+".xml",{useFeedTitle:false,popupSize:new OpenLayers.Size(popupWidth1,popupHeight1),'maxResolution':26.4583862501058,'icon':cimIcon});this.map.addLayer(this.layerRutes);this.layerRutes.maxResolution=26.4583862501058;this.ctrNavigation=new OpenLayers.Control.Navigation();this.map.addControl(this.ctrNavigation);this.map.addControl(new OpenLayers.Control.ScaleLine({maxWidth:200}));layerMapaGuia=new OpenLayers.Layer.ArcGISCache("Mapa guía","http://www.conselldemallorca.net/mapcache/MapaGuia/MAPA",{layername:'_alllayers',type:'png',tileOrigin:new OpenLayers.LonLat(-5120900,9998100),buffer:1});var options={maxExtent:new OpenLayers.Bounds(297777.5040216768,4145928.295656589056,731271.704343410944,4579422.4959783232),resolutions:new Array(846.668360003387,423.334180001693,211.667090000847,105.833545000423,52.9167725002117,26.4583862501058),maxResolution:846.668360003387,tileSize:new OpenLayers.Size(256,256),tileOrigin:new OpenLayers.LonLat(-5120900,9998100),projection:'EPSG:25831',units:'m'};var ovmap=new OpenLayers.Control.OverviewMap({layers:[layerMapaGuia],mapOptions:options});this.map.addControl(ovmap);ovmap.maximizeControl();this.map.events.register('popupopen',this,function(evt){if(evt.object.popups[0].feature.layer.name=='Rutes'){if(this.layerRutes.selectedFeature){var nom=this.layerRutes.selectedFeature.data.title;var recs=Ext.cim.rutes;for(i=0;i<recs.length;i++){var rec=recs[i];if(rec[1]==nom){app.cim_map.selectSenderisme(rec[0]);break;}}}}
Event.stop(evt);});}
cimSenderismeMap.prototype.getMap=function(){return this.map;}
cimSenderismeMap.prototype.getVisibleLayers=function(){var listLayers="";var layers=this.map.layers;var selLayer=8;var maxIndex=20;var opacity=-1;if(layers[1].getVisibility()){if(layers[1].opacity==1){listLayers+=(maxIndex-1);}else{listLayers+=maxIndex+' '+(maxIndex-1);opacity=Math.round((1-layers[2].opacity)*100);}}else{listLayers+=maxIndex;};for(i=2;i<selLayer;i++)if(layers[i].getVisibility())listLayers+=" "+(maxIndex-i);for(i=(selLayer+1);i<(layers.length-2);i++)if(layers[i].getVisibility())listLayers+=" "+(maxIndex-i+1);if(opacity!=-1)listLayers+="&opacity="+opacity;return listLayers;}
cimSenderismeMap.prototype.selectSenderisme=function(id){this.selectLayer.destroyFeatures();if(id!=select_id){this.selectLayer.addFeatures(listFeatures_geometry[id]);select_id=id;}else select_id="";}
function parseSenderismeData(req){var g=new OpenLayers.Format.GML();var features=g.read(req.responseText);for(var feat in features){for(var j in features[feat].attributes){if(j=="OBJECTID"){listFeatures_geometry[features[feat].attributes[j]]=features[feat];break;}}}
if(select_id!=""){if(listFeatures_geometry[select_id]){app.cim_map.map.zoomToExtent(listFeatures_geometry[select_id].geometry.getBounds());app.cim_map.selectLayer.addFeatures(listFeatures_geometry[select_id]);}}}
