[mapserver-users] can't set class obj's color in php
Daniel Morissette
morissette at dmsolutions.ca
Mon Jun 10 21:05:09 PDT 2002
Pushkar Pradhan wrote:
>
> $cl = array();
> for($c = 0; $c < count($tmp->numclasses); $c++) { // 2 classes in .map
> $cl[$c]= $tmp->getClass($c);
> echo "class index $c";
> $status = $cl[$c]->set("color", $map->addColor(255, 0, 0));
> }
>
> This code executes only once, browser displays echo statem. only once,
> the second layer must also be red but it doesn't change, I don't know if
> this is a php problem or mapscript is causing it to jump out of for loop.
You used:
for($c = 0; $c < count($tmp->numclasses); $c++)
$tmp->numclasses is an integer representing the number of classes, so
you shouldn't call count() on it... count() on a single integer always
returns 1 it seems.
Instead, simply use:
for($c = 0; $c < $tmp->numclasses; $c++)
--
------------------------------------------------------------
Daniel Morissette morissette at dmsolutions.ca
DM Solutions Group 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