Changes between Initial Version and Version 1 of PerlStyleObj4


Ignore:
Timestamp:
Jan 29, 2009, 11:27:57 AM (15 years ago)
Author:
jmckenna
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • PerlStyleObj4

    v1 v1  
     1= styleObj =
     2
     3Illustrating use of new 4.x styleObj, two approaches:
     4
     5== One - Using an existing style from map file. Default values will come from values set in map file. ==
     6{{{
     7#!perl
     8my $layerObj = $map->getLayerByName('data_points');
     9my $class = $layerObj->getClass(0);
     10# we only have one style in this layer.
     11my $style = $class->getStyle(0);
     12# change some sytle values
     13$style->{size} = 20;
     14$style->{color}->setRGB(255,0,0);
     15$layerObj->draw($map,$img);
     16}}}
     17
     18== Two - Creating a new style. All values must be set. ==
     19{{{
     20#!perl
     21my $circle_idx = $map->getSymbolByName('circle');
     22my $layerObj = $map->getLayerByName('data_points');
     23my $class = $layerObj->getClass(0);
     24my $style = new mapscript::styleObj();
     25$style->{symbol} = $circle_idx;
     26$style->{size} = 20;
     27$style->{color}->setRGB(255,0,0);
     28$style->{outlinecolor}->setRGB(0,0,0);
     29# insert the style in class
     30$class->insertStyle($style, 0);
     31$layerObj->draw($map,$img);
     32# remove the style, this is important when in a loop. There is a maximum of 5 styles/class.
     33$class->removeStyle(0);
     34}}}
     35== Map file fragment ==
     36{{{
     37LAYER
     38  NAME "data_points"
     39  TYPE POINT
     40  STATUS ON
     41  TEMPLATE "bogus.html"
     42  TOLERANCE 5
     43  CLASS
     44    STYLE
     45      SYMBOL "circle"
     46      SIZE 0
     47      COLOR 0 0 0
     48      OUTLINECOLOR 0 0 0
     49    END
     50  END
     51  PROJECTION
     52    "proj=latlong"
     53  END
     54END
     55}}}
     56
     57== Access to styles has been changed in version 4.2. ==
     58
     59$class->getStyle(0)->{symbol} = 0;
     60
     61(there is a hidden pen parameter that needs to be set)
     62
     63$style->setRGB(255, 0, 0);
     64
     65----
     66back to PerlMapScript