Even though I found a workaround that works for my application (generating the image first and later the accompying html page), the original problem still persists. <br><br>Just a short example of code (where the width and height are based on the extent, like in my application) and it's output. My hypothesis is that maybe the longitude/latitude values are the problem?
<br><br>dl('php_mapscript.so');<br>$oMap = ms_newMapObj('/home/johan/rwanda/start-print.map');<br>$mapExtent = $oMap->extent;<br>$oMap->setExtent($aExtent[0],$aExtent[1],$aExtent[2],$aExtent[3]);<br>
$tot = $oMap->numlayers;<br>$pw = 600;<br> $gw =$aExtent[2] - $aExtent[0];<br> $gh = $aExtent[3] - $aExtent[1];<br> $ph = ceil($pw*$gh/$gw);<br> $oMap->set('width', $pw);<br> $oMap->set('height', $ph);
<br>$oMap->selectOutputFormat('PNG');<br><br>var_dump($oMap->extent);<br>$oImg = $oMap->draw();<br>var_dump($oMap->extent);<br>die;<br><br>gives the following output:<br><pre>object(ms_rect_obj)#2 (5) {
<br> ["_handle_"]=><br> resource(3) of type (Unknown)<br> ["minx"]=><br> float(29.7975484895)<br> ["miny"]=><br> float(-1.93103563105)<br> ["maxx"]=><br> float(29.9594623555
)<br> ["maxy"]=><br> float(-1.80965089289)<br>}<br>(and after the draw method is called:)<br><br>object(ms_rect_obj)#2 (5) {<br> ["_handle_"]=><br> resource(3) of type (Unknown)<br> ["minx"]=>
<br> float(29.7596991183)<br> ["miny"]=><br> float(-1.93103563105)<br> ["maxx"]=><br> float(29.9973117267)<br> ["maxy"]=><br> float(-1.80965089289)<br>}<br></pre><br><div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br><br><br>2007/5/23, Johan Van de Wauw <<a href="mailto:johan.vandewauw@gmail.com">johan.vandewauw@gmail.com</a>>:<br>> Hello everyone,<br>><br>> When generating a map using mapscript, I notice that the extent changes
<br>> (slightly) after calling the "draw" operation.<br>> I don't seem to be the only one with this problem as eg the ka-map wiki<br>> says:<br>><br>> Print output is related to viewport but image extent correspondence in not
<br>> yet perfect.<br>><br>> Is there a way to make this correspondence better, or is there a way to<br>> get/predict the actual extent used in the image before (or without) calling<br>> the "draw" method?
<br>><br>> Johan<br>><br></blockquote></div><br>