wiki:SWIGMapScriptOpacity

Using setOpacity() method for SWIG MapScript

<?php

// define variables
define( "MAPFILE", "/ms4w/apps/local-demo/local.map" );

// open map
$oMap = new mapObj(MAPFILE);

//force all errors to display
//  comment out the next 2 lines, useful on servers not displaying errors
ini_set('display_errors','On');
error_reporting(E_ALL);

// set image size
$oMap->setsize(400, 300);

// set image format
$oMap->selectOutputFormat("png");


// get layer
$oPolyLayer = $oMap->getLayerByName('ocean');

//***********************************************************************************************
// set opacity on the layer
//***********************************************************************************************
// call setOpacity() (which actually creates a new COMPOSITE object)
$oPolyLayer->setOpacity(40);

// draw map
$oImage = $oMap->draw();

// save image file
//$file = $oImage->save("C:/ms4w/apps/local-demo/ttt.png",$oMap);

//***********************************************************************************************
// save mapfile to new file, to see your new COMPOSITE object inside the layer
//***********************************************************************************************
$oMap->save("C:/ms4w/apps/local-demo/output-opacity.map");

// set header
header("Content-type: image/png");

//send image to stdout (browser), without saving file locally
echo $oImage ->getBytes();

?>
Last modified 3 years ago Last modified on 2021-12-22T12:32:05-04:00
Note: See TracWiki for help on using the wiki.