[Mapserver-users] creating a new layer with PHP/Mapscript
eric.belenfant
eric.belenfant at ac-orleans-tours.fr
Mon Jul 5 00:18:14 PDT 2004
Norbert Thieme a écrit :
> eric.belenfant schrieb:
>
>> Hi,
>>
>> i'm using php mapscript 4.0 and .tab files from MAPINFO.
>> I try to generate some layers on the fly with php.
>> Here is the piece of code
>>
>> $couche_modele = $map->getLayerByName("couche_modele");
>> $modele_classe = $couche_modele->getClass(0);
>> /////////////////////////////////////////////
>> // Affichage/Masquage des couches
>> /////////////////////////////////////////////
>>
>> $layer = *ms_newLayerObj*($map,$couche_modele);
>> $layer->set("name","total_sts");
>> $layer->set("classitem","total_sts");
>> $class = ms_newClassObj($layer);
>> $class->setexpression("[total_sts]>0");
>> $style = ms_newStyleObj($class);
>> $style->color->setRGB(255,255,200);
>> $colorSTS = rgb2html(Array( $style->color->red,
>> $style->color->green,
>> $style->color->blue));
>>
>> if (isset($HTTP_POST_VARS["total_sts"])){
>> print_r($map->getLayersdrawingorder());
>> $layer->set("status",MS_ON);
>> $checkSTS="CHECKED";
>> }else
>> $layer->set("status",MS_OFF);
>>
>> The new layer i create is not visible, however all the propoerties of
>> the layer are OK when i echo them .
>>
>> What is wrong in my code ?
>> Am i missing something ?
>>
>> eric
>>
>> _______________________________________________
>> Mapserver-users mailing list
>> Mapserver-users at lists.gis.umn.edu
>> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
>>
>>
>
>
> Hi,
>
> could it be a problem with the projection or the extent? Has your map
> a projection set? Does the map extent fit the extent of your data
> without a projection?
>
> You can try to map->save to get a mapfile where you can check if
> everything looks good.
>
> Regards,
> Norbert
>
After some searchs, i found it was a problem with the STATUS
default/on/off.
The behaviour of default is strange for me because i thought the value
by default was on and then i was wondering why the layer did not appear
with the ON value but appeared with the DEFAULT value.
To debug the mapfiles i found it's a good thing to save the mapfile with
the save function in PHP.
eric
More information about the MapServer-users
mailing list