[ka-Map-users] KALegend bug fixed

Gabriele B gabbag981 at hotmail.com
Fri Jul 6 10:05:00 EDT 2007


Hi Sacha

no, My problem was with IE (version 6) that don't refreshes the 
checkboxes...

But I had your same problem ... May be I have the solution:

I created a php script that is a copy of legend.php but echoes javascript 
code to resize the images.

This is my script that I called legend_dim.php :

include_once('../include/config.php');
$jsString="";
if (!extension_loaded('MapScript'))
{
    dl( $szPHPMapScriptModule );
}

$groups = isset( $_REQUEST['g'] ) ? $_REQUEST['g'] : "";
$layers = isset( $_REQUEST['layers'] ) ? $_REQUEST['layers'] : "";

$oMap = ms_newMapObj($szMapFile);
$oPoint = ms_newPointObj( );
$oPoint->setXY($oMap->width/2, $oMap->height/2 );
$oMap->zoomScale( $_REQUEST['scale'], $oPoint, $oMap->width, $oMap->height, 
$oMap->extent );

$aszLayers = $aszGroups = array();

if ($groups || $layers)
{

    if ($layers)
    {
        $aszLayers = explode(",", $layers);
    }

    if ($groups)
    {
        $aszGroups = explode(",", $groups);
    }
    $nLayers = $oMap->numlayers;
    for($i=0;$i<$nLayers;$i++)
    {
        $oLayer = $oMap->getLayer($i);
        if (($aszGroups && in_array($oLayer->group,$aszGroups)) ||
            ($aszLayers && in_array($oLayer->name,$aszLayers)) ||
            ($aszGroups && $oLayer->group == '' &&
             in_array( "__base__", $aszGroups)))
        {

            $oLayer->set("status", MS_ON );


        }
        else
        {
            $oLayer->set("status", MS_OFF );
        }
    }
}



$oImg = $oMap->drawLegend();
$nLayers = $oMap->numlayers;
$gruppi =array();



		$indLayer = $oMap->getLayersIndexByGroup($aszGroups[0]);
		$indLayer = $indLayer[0];
		$aLayer = $oMap->getLayer($indLayer);
    $jsString.= "__img = getRawObject( 'legendImg_$aLayer->group'); 
if(__img){__img.width=$oImg->width;__img.height=$oImg->height;}";



echo "$jsString";

?>

Now I have to call this from KaLegend.js when the layers are created... In 
the kaLegend.update() function I added (after setting the src of the image)

	                 /  oImg.src = 'legend.php?map=' +
           set image src    -  this.kaMap.currentMap + '&scale=' + s + '&g=' 
+
                                 \  oLayer.name;


			       call('legend_dim.php?map=' +
                myCode---->    this.kaMap.currentMap + '&scale=' + s + '&g=' 
+
                               oLayer.name, this , evalFromPhp);


At this point I had to write a javascript function 'evalFromPhp' that 
evaluates the code returned by legend_dim.php :

function evalFromPhp(phpResult)
{

var __img=null;

eval(phpResult);

}

This should work but I must eval the results of php page for each layer. 
Otherwise I can set legend dimensions for all groups outside the for cycle
in the update function. But I don't want to stress my server with another 
"for" cycle.

Hope this helps




>From: "Sacha Black" <sacha.black at gmail.com>
>To: "Gabriele B" <gabbag981 at hotmail.com>
>CC: ka-map-users at lists.maptools.org
>Subject: Re: [ka-Map-users] KALegend bug fixed
>Date: Thu, 5 Jul 2007 16:39:25 -0700
>
>hi Gabriele,
>
>what was the bug exactly? i'm asking because i was just doing some
>testing and i saw a strange thing in IE 6.
>
>in my case, for a relatively simple map file with 8 layers in the
>_BASE_ group, the legend displays as expected in Firefox 1.5, 2.0,
>Opera 9.2, IE 7. The dimensions of the legend image generated is
>180x149 pixels in this case.
>
>however in IE 6 the same legend is displayed highly squished at 103 x
>23 pixels. i was wondering what could cause this?
>
>sacha
>
>On 7/2/07, Gabriele B <gabbag981 at hotmail.com> wrote:
>>hi list
>>there was a ploblem with IE when Kamap creates the div for the legend. I
>>just added an Id for each
>>checkbox input (in the createLayerHTML() method) and wrote a new method in
>>KaLegend.js that uses document.getElementById() function to set the right
>>status of the checkboxes. It seems to work well when changing map and when
>>adding layers (e.g. queryLayer). If I have time I can test with other
>>browser and find a way to provide this function to browser that haven't
>>document.getElementById().
>>
>>ciao :)
>>
>>_________________________________________________________________
>>Windows Live OneCare: tutto per la cura del tuo PC ! Provalo Gratis!
>>http://onecare.live.com/standard/it-it/default.htm
>>
>>_______________________________________________
>>ka-Map-users mailing list
>>ka-Map-users at lists.maptools.org
>>http://lists.maptools.org/mailman/listinfo/ka-map-users
>>

_________________________________________________________________
Scarica Windows Live Messenger e chiama gratis in tutto il mondo! 
http://www.messenger.it/connessione.html



More information about the ka-Map-users mailing list