Can't get .png Location Marker to show transparencies via code

Christopher Harris docterrobert at MSN.COM
Fri Oct 5 13:51:08 PDT 2007


Hi.  I have been trying to figure this out for quite a while.  I have this working within a .map file, but if I set it up exactly the same way with php, it never works.  I'm using Firefox to test it, not IE6 (in case someone thinks it's due to IE6 not supporting .png's.  The .map file contains the first marker, which works.  The .php file attempts to make the second marker use a transparent background.  One interesting thing that I've noticed is if I add jibberish to the parameter in this line: $markerLayer->set(transparency, MS_GD_ALPHA); so as to make the app break, nothing happens.  The app doesn't throw up any error messages and continues to render the second marker without transparencies.

Here is my .map file that works.  I put the United States example off the mapserver site to use as a "background" so I could pin my markers via lat/lon and know where I was.  So, that's why that's there.  I could give a crap about all that.  The marker layer is at the bottom.

NAME USA1
    STATUS ON
    DEBUG ON
    SIZE 800 500
    IMAGETYPE PNG
    IMAGECOLOR 140 140 140
    SHAPEPATH "/var/www/mapserver/campuscomber/data/statesp020/"
    EXTENT -89.248281 39.082274 -87.205980 41.117268
    UNITS DD
    PROJECTION
    "proj=latlong" "ellps=GRS80" "datum=NAD83"
    END
    WEB
        IMAGEPATH "/var/www/mapserver/campuscomber/images/"
        IMAGEURL "/mapserver/campuscomber/images/"
    END
    OUTPUTFORMAT
        NAME gif
      DRIVER "GD/GIF"
      MIMETYPE "image/gif"
      IMAGEMODE RGBA
      EXTENSION "gif"
    END
    OUTPUTFORMAT
      NAME png
      DRIVER "GD/PNG"
      MIMETYPE "image/png"
      IMAGEMODE RGBA
      EXTENSION "png"
    END

    LAYER
        NAME "US state boundaries"
        TYPE POLYGON
        STATUS ON
        DATA "statesp020"
        PROJECTION
            "proj=latlong"
            "ellps=GRS80"
            "datum=NAD83"
        END
        CLASS
            NAME "US states"
            OUTLINECOLOR 0 0 0
            COLOR 80 80 0
            SYMBOL 0
        END
    END
    
    LAYER
        NAME "credits"
        STATUS DEFAULT
        TRANSFORM FALSE
        TYPE ANNOTATION
        FEATURE
            POINTS
                10 480
            END
            TEXT 'Made with Mapserver.'
        END
        CLASS
            LABEL
                TYPE BITMAP
                POSITION CR
                COLOR 250 250 0
            END
        END
    END
    
    LAYER
        NAME "Marker"
        TYPE POINT
        STATUS DEFAULT
        TRANSPARENCY ALPHA
        CLASS
            STYLE
                SYMBOL 'data/statesp020/red_dot.png'
                SIZE 15
            END
        END
        FEATURE
                POINTS
                    -88.228841 40.104796
                END
            END  
    END
END


Here's the .php file with marker #2:
<?php
//dl("php_mapscript.so");

$map_file="./markerTest.map";
$map = ms_newMapObj($map_file);

$markerLayer = ms_newLayerObj($map);
$markerLayer->set(name, "Marker2");
$markerLayer->set(type, MS_LAYER_POINT);
$markerLayer->set(status, MS_DEFAULT);
$markerLayer->set(transparency, MS_GD_ALPHA);
//Location Marker layer class
$markerClass = ms_newClassObj($markerLayer);
//Location Marker layer class style
$markerStyle = ms_newStyleObj($markerClass);
//Gives the location of the symbol to place as a marker
$markerStyle->set(symbolname, "data/statesp020/red_dot.png");
//Sets the size of the marker.  The bigger, the badder.......
$markerStyle->set(size, 15);

$image=$map->draw();

$markerPoint = ms_newPointObj();
$markerPoint->setXY(-88.227167, 41.015752);
$markerLine = ms_newLineObj();
//$markerLine->addXY(-88.227167, 41.015752);
$markerLine->add($markerPoint);
$markerShape = ms_newShapeObj(MS_SHAPE_POINT);
$markerShape->add($markerLine);
$markerLayer->addFeature($markerShape);
$layer=$map->getLayerByName("Marker2");
//Draws the point using the map, layer Marker2, and the image generated
$markerShape->draw($map, $layer, $image);

$image_url=$image->saveWebImage();

?>
 <html>
 <head>
 <title>US state boundaries and Marker Test</title>
 </head>
 <body>
<img src="<?php echo $image_url?>">

 <p>
 Marker Test
 </p>

 </body>
</html>


Thanks in advance.

 - Chris

_________________________________________________________________
Boo! Scare away worms, viruses and so much more! Try Windows Live OneCare!
http://onecare.live.com/standard/en-us/purchase/trial.aspx?s_cid=wl_hotmailnews
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20071005/be20e79e/attachment.htm>


More information about the MapServer-users mailing list