| | 1 | <?php |
| | 2 | |
| | 3 | <?php |
| | 4 | |
| | 5 | // define variables |
| | 6 | define( "MAPFILE", "C:/ms4w/apps/phpmapscriptng-swig/output.map" ); |
| | 7 | |
| | 8 | // required SWIG include (contains constants for PHP7) |
| | 9 | include("C:/ms4w/apps/phpmapscriptng-swig/include/mapscript.php"); |
| | 10 | |
| | 11 | // open map |
| | 12 | $oMap = new mapObj(MAPFILE); |
| | 13 | |
| | 14 | //force all errors to display |
| | 15 | // comment out the next 2 lines, useful on servers not displaying errors |
| | 16 | ini_set('display_errors','On'); |
| | 17 | error_reporting(E_ALL); |
| | 18 | |
| | 19 | // set image size |
| | 20 | $oMap->setsize(400, 300); |
| | 21 | |
| | 22 | // set image format |
| | 23 | $oMap->selectoutputformat("png"); |
| | 24 | |
| | 25 | |
| | 26 | // get layer |
| | 27 | $oPolyLayer = $oMap->getLayerByName('prov_bound'); |
| | 28 | // set opacity (actually creates a new COMPOSITE object) |
| | 29 | $oPolyLayer->setOpacity(40); |
| | 30 | |
| | 31 | // draw map |
| | 32 | $oImage = $oMap->draw(); |
| | 33 | |
| | 34 | // save image file |
| | 35 | $file = $oImage->save("C:/ms4w/apps/phpmapscriptng-swig/ttt.png",$oMap); |
| | 36 | |
| | 37 | // save mapfile to new file |
| | 38 | $oMap->save("C:/ms4w/apps/phpmapscriptng-swig/output2.map"); |
| | 39 | |
| | 40 | // set header |
| | 41 | header("Content-type: image/gif"); |
| | 42 | |
| | 43 | // read image to output buffer |
| | 44 | readfile("C:/ms4w/apps/phpmapscriptng-swig/ttt.png"); |
| | 45 | |
| | 46 | ?> |
| | 47 | |
| | 48 | ?> |