[ka-Map-users] PNG transparency not supported in internet explorer

Paul Spencer pspencer at dmsolutions.ca
Thu Aug 4 08:38:15 EDT 2005


Jacob,

I would caution against the indiscriminate use of this hack as I ran 
into problems with it being applied to 8bit pngs.

I ultimately got it working for my purposes by setting a class on each 
image I wanted the hack applied to (pngHack) and modifying the behaviour 
so that it checked the className of the image before applying the hack.

One way to work around this is for you to have a modified createImage 
function in kaMap.js that adds the necessary style tag to the images as 
they are created.  Then you wouldn't need the css/htc file.  This could 
even be done conditionally on the current browser.

If you want to pursue the imagetype per group option (perhaps as well?) 
then I would suggest using metadata on the layers.  You would have to 
modify init.php to check for the metadata and pass it to the _layer 
constructor.  You would have to modify _layer in kaMap.js.  You would 
have to modify setTile in kaMap.js to append the additional parameters 
to the tile URL for each image.  And you would have to modify tile.php 
to check for additional parameters coming from $_GET and take 
appropriate action.

It is not actually necessary to modify kaMap in this case, though ... 
you can create your own _layer subclass in a separate js file:

function _png24Layer(szName,bVisible,opacity)
{
     _layer.apply( this, [szName,bVisible,opacity] );
     this.setTile = _png24Layer_setTile;
}

function _png24Layer_setTile(img)
{
     //copy from _layer_setTile
     var szForce = '';
     var szLayers = '';
     if (arguments[1])
         szForce = '&force=true';
     var szGroup = "&g="+img.layer.domObj.id;
     var szScale = '&s='+this._map.aScales[this._map.currentScale];
     var l = safeParseInt(img.style.left) + this._map.kaMap.xOrigin;
     var t = safeParseInt(img.style.top) + this._map.kaMap.yOrigin;
     var src = this._map.kaMap.server+
               this._map.kaMap.tileURL+
               '?map='+this._map.name+
               '&t='+t+
               '&l='+l+
               szScale+szForce+szGroup;

     //pass desired format to source
     src = src + "&format=png24";

     if (isIE4)
     {
         //apply png24 hack for IE
         img.style.visibility = 'hidden';
         img.src = this._map.kaMap.aPixel.src;
         img.style.filter = 
"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"', 
sizingMethod='scale')";
     }
     else
     {

         if (img.src != src)
         {
             img.style.visibility = 'hidden';
             img.src = this._map.kaMap.server+
                   this._map.kaMap.tileURL+
                   '?map='+this._map.name+
                   '&t='+t+
                   '&l='+l+
                   szScale+szForce+szGroup;
         }
     }
}

then in init.php, you create a _png24Layer instead of a _layer.  You 
then modify tile.php to detect format in the $_GET to switch the format 
before rendering the tile.

If you can get this to work, I would actually be interested in putting 
this all into the kaMap core by making format a property of the _layer 
object.

Cheers

Paul

Jacob Delfos wrote:
> Emil,
>  
> Thanks for that info. I wasn't aware of it. You'd have thought Microsoft 
> would have fixed that up a while ago.
>  
> I guess I'll have to use gif to get transparency. Would be good if the 
> imagetype could be different for each layer, to be able to keep 24bit 
> colour. I might look into doing that. Worked well for me in Chameleon.
>  
> regards,
>  
> Jacob
>  
>  
>  
> --------------------------------------------------------------------------------
> From: Emil Zegers [mailto:taatuut at planet.nl]
> Sent: 4 August 2005 14:26
> To: Delfos, Jacob; ka-map-users at lists.maptools.org 
> <mailto:ka-map-users at lists.maptools.org>
> Subject: RE: [ka-Map-users] PNG transparency not supported in internet 
> explorer
>  
> 
> Hello Jacob,
>  
> At the moment IE 5.5+ does not properly support PNG transparancy (IE7 
> beta does, see http://blogs.msdn.com/ie/archive/2005/07/29/445242.aspx)
>  
> However, there are some hacks to provide PNG transparancy for 24/32 bit 
> PNG's in IE 5.5+, some are listed at 
> http://blogs.msdn.com/ie/archive/2005/04/26/412263.aspx.
>  
> A good one is the hack at webfx 
> http://webfx.eae.net/dhtml/pngbehavior/pngbehavior.html
>  
> Of course do not forget to question yourself if using hacks for this is 
> what you want. On the other hand if you want to support PNG transparancy 
> for IE this is a nice solution.
>  
> Regards,
>  
> Emil
> -----Original Message-----
> From: ka-map-users-bounces at lists.maptools.org 
> <mailto:ka-map-users-bounces at lists.maptools.org> 
> [mailto:ka-map-users-bounces at lists.maptools.org]On Behalf Of Delfos, Jacob
> Sent: donderdag 4 augustus 2005 4:32
> To: ka-map-users at lists.maptools.org <mailto:ka-map-users at lists.maptools.org>
> Subject: [ka-Map-users] PNG transparency not supported in internet explorer
>  
> 
> Hi all,
>  
> Just figured out why Internet Explorer keeps coming up with a blank map, 
> but not sure how to fix it. It would appear that Internet Explorer does 
> not support the PNG transparency that mapserver outputs. So my 
> transparent vector layers come out perfectly white where there's no 
> data. Firefox does support it, though. In the screenshot you can see a 
> normal tile and a transparent tile next to one another. The tile comes 
> out transparent in firefox, but not in internet explorer. Has anyone 
> else had this? And.... anything I can do about it?
>  
> Not sure of this is in Bugzilla. Seems bugzilla for Ka-Map is down......
>  
> Regards,
>  
> Jacob
>  
>  
>  
> <<kamap.jpg>>
>  
> JACOB DELFOS
> SPATIAL INFORMATION ANALYST
> Maunsell Australia Pty Ltd
> 629 Newcastle Street, Leederville, WA 6007
> PO Box 81, Leederville, WA 6902
> Western Australia
> ABN 20 093 846 925
>  
> Tel     + 61 8 9281 6185
> Fax    + 61 8 9281 6297
> jacob.delfos at maunsell.com <mailto:jacob.delfos at maunsell.com>
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> ka-Map-users mailing list
> ka-Map-users at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/ka-map-users

-- 
+-----------------------------------------------------------------+
|Paul Spencer                           pspencer at dmsolutions.ca   |
+-----------------------------------------------------------------+
|Applications & Software Development                              |
|DM Solutions Group Inc                 http://www.dmsolutions.ca/|
+-----------------------------------------------------------------+


More information about the ka-Map-users mailing list