How-to modify DATA in LAYER with PHP mapscript?

Daniel Morissette dmorissette at MAPGEARS.COM
Mon Dec 24 04:35:42 PST 2007


Dave Nuttall wrote:
> I've been able to generate a map using the OGR CONNECTIONTYPE to pull data
> from a MySQL table.
> 
> Each record contains the geometry and extents and I've figured out how to
> set the  extents before drawing the map.  However, if I could dynamically
> modify the DATA element of a layer's CONNECTION, the end result would be
> much better.
> 
> When I dump the $map array, I don't see an element that corresponds to the
> CONNECTIONTYPE or the DATA string for the OGR connection.
> 

The CONNECTIONTYPE, CONNECTION and DATA elements are members of the 
layerobject, not the map object. Try something like this::

   $layer = $map->getLayerByName('yourlayername');
   $layer->set('connectiontype', MS_OGR);
   $layer->set('connection', 'new value');
   $layer->set('data', 'new value');


> I'd be grateful if someone could post the equivalent to what I use to change
> the EXTENT for the current map.  I use something like this:
>   <?php
>     $row=mysql_fetch_assoc($result);
>     $map->setExtent($row['x1'],$row['y1'],$row['x2'],$row['y2']);
>     $image->$map->draw();
>    // then show the result
> ?>
> 

Using $map->setExtent() is the right way to go.

Maybe I misunderstood the question or what you're trying to achieve?

Daniel
-- 
Daniel Morissette
http://www.mapgears.com/



More information about the MapServer-users mailing list