|
||||
[maplab-users] help retrieve current extentsPaul Spencer spencer@dmsolutions.caWed, 08 Jan 2003 15:57:52 -0500
|
Thomas, you should be able to do something like this at the top of your script. This assumes that you have placed the script in the same directory as the application: <? include_once( "globprefs.php" ); /* ===================================================================== * Re-instate the previous map state * ===================================================================== */ // determine previous state key if ( isset( $http_form_vars["PrevStateKey"] ) ) $szPrevStateKey = $http_form_vars["PrevStateKey"]; else $szPrevStateKey = ""; // restore the previous state $oMapSession->restoreState( $szPrevStateKey, MAPFILE ); $map = $oMapSession->oMap; //the rest of your script here $p = PDF_new(); PDF_open_file($p, ""); $map->set(width,1200); $map->set(height,1200); $element=$map->draw(); $imagefile=$element->saveWebImage(MS_PNG,0,0,0); $image = PDF_open_image_file($p, "png", "c:/www/apache/htdocs/$imagefile"); if (!$image) { die("Couldn't open image ".$imagefile); } $width = PDF_get_value($p, "imagewidth", $image); $height = PDF_get_value($p, "imageheight", $image); PDF_begin_page($p, $width, $height); PDF_place_image($p, $image, 0, 0, 1); PDF_close_image($p, $image); PDF_end_page($p); PDF_close($p); $buf = PDF_get_buffer($p); $len = strlen($buf); header("Content-type: application/pdf"); header("Content-Length: $len"); header("Content-Disposition: inline; filename=image.pdf"); print $buf; PDF_delete($p); ?> The globprefs.php file sets up a number of variables and structures from the PHP session that can be used to restore the user's map state. The code after the include actually does restore the previous state of the map. And then your code starts ;) Cheers, Paul Thomas van den Berg wrote: > Hi all, > > I'm following the guidelines on > http://mapserver.gis.umn.edu/cgi-bin/wiki.pl?PHPMapscriptPDF > to allow saving to pdf from my gmapfactory > application. I'm able to do that straight from the > mapfile but not for user extent or selected layers. To > set the map file into the state the user is expecting, > I need to maintain in my script the arrays in the > gmapfactory application that record: > > - The current extent > - Layer status > > I'm new to php & phpmapscript and have not been able > to find those arrays (I'm totally lost). I would > appreciate any hint. I have attached my script. > > Thanks, > Thomas vd Berg > > > __________________________________________________ > Do you Yahoo!? > Yahoo! Mail Plus - Powerful. Affordable. Sign up now. > http://mailplus.yahoo.com -- Paul Spencer Applications and Software Development DM Solutions Group Inc. http://www.dmsolutions.ca
This archive was generated by Pipermail. |
MapTools.org -- Hosted by DM Solutions Group |