[maplab-users] help retrieve current extents

Paul Spencer
Wed, 08 Jan 2003 15:57:52 -0500

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"];
     $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, "");



$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);


$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;


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 ;)



Thomas van den Berg wrote:
> Hi all,
> I'm following the guidelines on
> 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.

Paul Spencer
Applications and Software Development
DM Solutions Group Inc.

This archive was generated by Pipermail.