Having hard time adding layers with php

Berend Veldkamp berend.veldkamp at aris.nl
Wed Nov 15 04:14:58 EST 2000


Assefa,
Thanks for the reply, unfortunately it didn't work for me, but it did point
me to a solution. I do:

$layer->set("status", MS_ON);
$img = $map->draw();

btw Can anyone tell me the difference between $layer->set("status", MS_ON);
and $layer->status = MS_ON; According to the docs 'status' isn't read-only so
it should work either way?

Berend


Assefa Yewondwossen wrote:

> Hi There,
>
>  You should use  $layer->set("status", MS_ON) to set the layer on.
>
>  Here is a simple example of something similar to your example.
>
>   $gpoMap = ms_newMapObj("gmap75.map");
>   $img = $gpoMap->draw();
>
>   $layer = $gpoMap->getLayerByName ("park");
>   $layer->set("status", MS_ON);
>   $layer->draw($img);
>
>    $url = $img->saveWebImage(0, 0);
>    printf("<IMG SRC=%s WIDTH=%d HEIGHT=%d>\n", $url, $gpoMap->width,
> $gpoMap->height);
>
>  hope it helps,
>
> Berend Veldkamp wrote:
>
> > Hi all,
> > I have the feeling I'm missing something obvious. What I want to do is
> > add certain layers from my mapfile, in PHP. This is what I have come up
> > with, so far:
> >
> > $map = ms_newMapObj ("wm12.map");
> > $img = $map->draw();
> > $layer = $map->getLayerByName ("roads");
> > // printf ("%s\n", $layer->name); // It's there
> > $layer->draw ($img);
> >
> > But PHP stops while doing this last statement, without giving any error
> > messages.
> > I have also tried setting $layer->status to MS_ON before calling
> > $map->draw(), this doesn't work either:
> >
> > $map = ms_newMapObj ("wm12.map");
> > $layer = $map->getLayerByName ("roads");
> > $layer->status = MS_ON;  // Now it's ON
> >
> > // Testing purpose:
> > // $layer = $map->getLayerByName ("roads");
> > // printf ("%d\n", $layer->status); // Now it's OFF again
> >
> > $img = $map->draw();
> >
> > Can anyone shed some light on this, I have a nightly build from a week
> > ago and PHP 4.0.3pl1
> >
> > Berend
> >
> > --
> > _________________________________________________
> >
> > ARIS - Hooghiemstraplein 126 - NL 3514 AZ Utrecht
> > tel. +31 30 2769180    -    fax. +31 30 2733578
> > URL: http://www.aris.nl/
> > _________________________________________________
>
> --
> ----------------------------------------------------------------
> Assefa Yewondwossen
> Software Analyst
>
> Email: assefa at dmsolutions.on.ca
> http://www.dmsolutions.on.ca
>
> Phone: (613) 565-5056
> ----------------------------------------------------------------

--
_________________________________________________

ARIS - Hooghiemstraplein 126 - NL 3514 AZ Utrecht
tel. +31 30 2769180    -    fax. +31 30 2733578
URL: http://www.aris.nl/
_________________________________________________





More information about the mapserver-users mailing list