Map extent in MapScript

Daniel Morissette morissette at dmsolutions.ca
Thu Dec 14 10:26:48 EST 2000


Thorsten Fischer wrote:
> 
> My MapScript in PHP
> looks like:
> 
> 1: $shpfname = "shape";
> 2: $shpf = ms_newShapefileObj ($shpfname, -1);
> 3: $myshape = $shpf -> getShape ($idx);
> 4: $mybounds = $myshape -> bounds;
> 5: $map = ms_newMapObj ("dyn.map");
> 6: $map -> set ("height", 300);
> 7: $map -> set ("width", 300);
> 8: $map -> extent = $mybounds;
> 
> The last line is crucial, because leaving it out or leaving it in does not
> change the resulting image at all. Any ideas?
> 

You have to use the setextent() method to set the map extents:

  $map->setextent($mybounds->minx, $mybounds->miny,
                  $mybounds->maxx, $mybounds->maxy);

You always have to use the set() methods to set object properties in PHP
MapScript.  Setting $map->extent = ...; directly changes the value in
the PHP object itself but does not propagate automatically to the real
map object internally.  This is because there is no way to set callbacks
on property changes when we implement PHP objects in C.  Hopefully this
is something that will be added in PHP 4 at some point.

-- 
------------------------------------------------------------
 Daniel Morissette                morissette at dmsolutions.ca
                 http://www.dmsolutions.ca/
------------------------------------------------------------
  Don't put for tomorrow what you can do today, because if 
      you enjoy it today you can do it again tomorrow.




More information about the mapserver-users mailing list