[Mapbender-users] Funcionality Opacity: modifications of mapbender files to change opacity image

Emilio Pardo emilio.pardo.ext at juntadeandalucia.es
Thu Mar 15 04:09:15 EDT 2007


Hallo

Another day I did a question about  the possibility of mody the opacity 
of the different images when you connect with more than one wms server. 
The response was that was not implemented.

 A good friend (Virgilio Rey)  has done the code modifications to have 
this functionality,

 It is necessary to modify three files

                        Map.php

                        Map_obj.js

                        mod_WMSpreferences.php

 

CHANGES IN MAP.PHP

 

/*Change to Opacity*/

/* [VRL 14/03/07] leemos el valor de mb_mapObj[i].gui_wms_mapopacity y 
lo asignamos al estilo en distintos formatos */

 cadenaOpacity = "opacity:"+mb_mapObj[i].wms[ii].gui_wms_mapopacity+"; 
Filter: Alpha(Opacity="+mb_mapObj[i].wms[ii].gui_wms_mapopacity*100+"); 
-moz-opacity:"+mb_mapObj[i].wms[ii].gui_wms_mapopacity+" ; 
-khtml-opacity:"+mb_mapObj[i].wms[ii].gui_wms_mapopacity;

 newMapRequest += "<div id='"+myDivId+"' style=\"position:absolute; 
top:0px; left:0px; z-index:'"+ii+"';"+cadenaOpacity+"\">";

/*End Change to Opacity*/


ORIGINAL

newMapRequest += "<div id='"+myDivId+"' style='position:absolute; 
top:0px; left:0px; z-index:"+ii+"; '>";

 

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

CHANGES IN MAP_OBJ.JS

 

/*Change to Opacity*/

/* [VRL 14/03/07] definimos gui_wms_mapopacity inicializado a 1 */

                this.gui_wms_mapopacity = 1 ;      

/* End Change to Opacity*/

 

Include this line in at the end pf function wms_const

 

 

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


 CHANGES IN MOD_WMSPREFERENCES.PHP

Add these functions

 

/*Change to Opacity*/

/*

   Hay que buscar donde se define mb_mapObj[] y añadirle el valor 
gui_wms_mapopacity

   que será donde se guarde el valor de la opacidad. [Se se puede poner 
el valor 1 mejor]

   Por otro lado, en el "map" hay que leer ese valor de 
gui_wms_mapopacity y asignárselo al "opacity: "

*/

function setMapOpacity(val){

                var tmp = val.split(",");

                my.wms[tmp[0]].gui_wms_mapopacity = tmp[1];

                loadWMS();

}

 

function cambia_opacity(id,incremento)

{

    objeto = opener.mapframe1.document.getElementById('div_'+id);

    opacity = objeto.style.opacity*100 - (-incremento);

    opacity = (opacity < 100)? ((opacity > 0)? opacity : 0) : 100;

 

   objeto.style.opacity = (opacity / 100);

   objeto.style.MozOpacity = (opacity / 100);

   objeto.style.KhtmlOpacity = (opacity / 100);

   objeto.style.filter = "alpha(opacity=" + opacity + ")";

 

/* End Change to Opacity*/

 

   setMapOpacity(id+","+(opacity / 100));

}

 

Change the table  and include one row

 

/*Change to Opacity*/

 

                               /* [VRL 13/03/07] Modificado para leer el 
valor de la opacity almacenado en gui_wms_mapopacity */

                               str += "<tr><td>Cambiar 
Opacidad:</td><td><input type=\"button\" 
onclick=\"cambia_opacity('"+visibleWmsIndexArray[i]+"','-10')\" 
value=\"-\">";

                               str += "<input 
id=\"valor_opacity_"+visibleWmsIndexArray[i]+"\" type=\"text\" 
disabled=\"disabled\" size=\"3\" 
value=\""+my.wms[visibleWmsIndexArray[i]].gui_wms_mapopacity*100+" %\">";

                               str += "<input type=\"button\" 
onclick=\"cambia_opacity('"+visibleWmsIndexArray[i]+"','+10')\" 
value=\"+\">";

                               str += "</td></tr>";

                /* End Change to Opacity*/

 

 

 

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

 

Sorry but the coment of the autor is in Spanish

These changes have been realized to the version  Mapbender 2.4.0 I do 
not believe that there are problems with the new version 2.4.1

 If some one need the files I´ll send by mail.

-- 
-------------- next part --------------
Skipped content of type multipart/related


More information about the Mapbender_users mailing list