Mapscript adding class with PHP

Eijnden, Bart van den (AGI) b.vdeijnden at AGI.RWS.MINVENW.NL
Wed Oct 4 05:25:23 EDT 2006


Arie,

can you save your MAP using 

$map->save('<filename>');

?

And post the output LAYER definition?

Also, have you set CLASSITEM on your LAYER?

Best regards,
Bart

-----Oorspronkelijk bericht-----
Van: Arie Mijnlieff [mailto:mijnlief at xs4all.nl]
Verzonden: woensdag 4 oktober 2006 11:03
Aan: Eijnden, Bart van den (AGI)
CC: MAPSERVER-USERS at LISTS.UMN.EDU
Onderwerp: Re: [UMN_MAPSERVER-USERS] Mapscript adding class with PHP


Bart !

My code is now:

$this_layer = $map->getLayerByName('countries');

$new_class = ms_newClassObj($this_layer);

$new_class->setExpression('Russia');
$new_class->set('name','Russia');
$new_class->label->outlinecolor->setRGB(255,255,255);
$new_class->label->set(minfeaturesize,40);
$new_style = ms_newStyleObj($new_class);
$new_style->color->setRGB(100,100,100);
$new_style->outlinecolor->setRGB(255,255,255);

$img=$map->draw();

$img->saveImage("/var/www/html/mapdemo/images/test.jpg");

Doesnt work however..

I really appreciate your help !

Arie

On 4-okt-2006, at 10:06, Eijnden, Bart van den (AGI) wrote:

> Arie,
>
> you can best use a style object. Example:
>
>     $oClass = ms_newClassObj($oLayer);
>     $oStyle = ms_newStyleObj($oClass);
>
>     $aColor[0] = 0;
>     $aColor[1] = 0;
>     $aColor[2] = 0;
>     if ($HTTP_FORM_VARS["COLOR"]!= "")
>       $aColor = explode(",", $HTTP_FORM_VARS["COLOR"]);
>
>     $oStyle->color->setRGB($aColor[0], $aColor[1], $aColor[2]);
>
> Best regards,
> Bart
>
> -----Oorspronkelijk bericht-----
> Van: UMN MapServer Users List
> [mailto:MAPSERVER-USERS at LISTS.UMN.EDU]Namens Arie Mijnlieff
> Verzonden: woensdag 4 oktober 2006 10:06
> Aan: MAPSERVER-USERS at LISTS.UMN.EDU
> Onderwerp: Re: [UMN_MAPSERVER-USERS] Mapscript adding class with PHP
>
>
> Hi Murat !
>
> No this doesnt solve the problem:
>
> PHP Fatal error:  Call to a member function on a non-object in /var/
> www/html/mapdemo/bulgaria/test.php on line 13
>
> color is not an attribute of the class object.. Maybe i should try to
> define a new layer with php for each country that i would like to
> paint..
>
> Thanks for your suggestion !
>
> Arie
>
> On 4-okt-2006, at 8:38, Murat BEYHAN wrote:
>
>> Hi Arie,
>>
>> please try the following in yor php script,
>> I'm new on PhpMapscript so. I hope this solve your problem
>>
>>
>>
>>
>>
>>> $new_class = ms_newClassObj($this_layer);
>>> $new_class->setExpression('Australia');
>>> $new_class->set('name','Australia');
>>   $new_class->color->setRGB(255,0,0);////////////////here you
>> should add
>>> $new_class->label->outlinecolor->setRGB(255,255,255);
>>> $new_class->label->set(minfeaturesize,40);
>>
>> regards
>>
>> Murat
>>
>> On Tue, 3 Oct 2006 21:35:33 +0200, Arie Mijnlieff wrote
>>> Hi,
>>>
>>> I want to show countries in my world map based on a form with
>>> checkboxes.
>>>
>>> If I check Argentina and Australia i would like to show both
>>> countries in red, whereas the other are in another color. If i
>>> change  the selection in Australia and India i would like Australia
>>> and India  to be red.
>>>
>>> I have a .map file with a layer called countries. In that layer i
>>> have a class:
>>>
>>>     CLASS                   # Start of CLASS object
>>>        NAME 'Argentina'
>>>        EXPRESSION 'Argentina'
>>>        OUTLINECOLOR 100 100 100
>>> 	  COLOR 255 255 150
>>>        LABEL
>>> 	   SIZE LARGE
>>> 	   OUTLINECOLOR 255 255 255
>>> 	   MINFEATURESIZE 40
>>>        END
>>>      END                     # End of CLASS object
>>>
>>> So i thought if Australia is checked, i add a class object to my
>>> layer using php with the same colors:
>>>
>>> $new_class = ms_newClassObj($this_layer);
>>> $new_class->setExpression('Australia');
>>> $new_class->set('name','Australia');
>>> $new_class->label->outlinecolor->setRGB(255,255,255);
>>> $new_class->label->set(minfeaturesize,40);
>>>
>>> Australia will not be red however. I do not understand how i can
>>> change the color of my new class. I succeeded only to change the
>>> color of the label.. What do i do wrong ?
>>>
>>> If i change the color of an existing class i can see that change
>>> however..
>>>
>>> $my_class = $this_layer->getClass(0);
>>> $my_class->setExpression('Australia');
>>> $my_class->set('name','Australia');
>>>
>>> Any help will be appreciated !!
>>>
>>> Arie
>>>
>>> --  
>>> This message has been scanned for viruses and
>>> dangerous content by MailScanner, and is
>>> believed to be clean.
>>
>>
>> --
>> Open WebMail Project (http://openwebmail.org)
>>
>>
>> --  
>> This message has been scanned for viruses and
>> dangerous content by MailScanner, and is
>> believed to be clean.
>>
>
>
> Disclaimer
> ********************************************************************** 
> **
> Aan dit bericht kunnen geen rechten worden ontleend. Dit bericht is
> uitsluitend bestemd voor de geadresseerde. Als u dit bericht per abuis
> hebt ontvangen, wordt u verzocht het te vernietigen en de afzender te
> informeren. Wij adviseren u om bij twijfel over de juistheid of de
> volledigheid van de mail contact met afzender op te nemen.
>
> This message shall not constitute any rights or obligations.
> This message is intended solely for the addressee.
> If you have received this message in error, please delete it and
> notify the sender immediately. When in doubt whether this message
> is correct or complete, please contact the sender.
> ********************************************************************** 
> **
>
>



Disclaimer
************************************************************************
Aan dit bericht kunnen geen rechten worden ontleend. Dit bericht is
uitsluitend bestemd voor de geadresseerde. Als u dit bericht per abuis
hebt ontvangen, wordt u verzocht het te vernietigen en de afzender te
informeren. Wij adviseren u om bij twijfel over de juistheid of de
volledigheid van de mail contact met afzender op te nemen.

This message shall not constitute any rights or obligations.
This message is intended solely for the addressee.
If you have received this message in error, please delete it and
notify the sender immediately. When in doubt whether this message
is correct or complete, please contact the sender.
************************************************************************



More information about the mapserver-users mailing list