Example - Creating A Layer That Uses Area Rules

This example shows how to create a new layer using the factory. This layer uses three area rules to theme parcels by their square footage.

        // ...

      /---------------------------------------------------//

     $factory = new LayerDefinitionFactory();

     /// Create three area rules for three different

     // scale ranges.

     $areaRule1 = $factory->CreateAreaRule(    '1 to 800',

       'SQFT &gt;= 1 AND SQFT &lt; 800',     'FFFFFF00');

     $areaRule2 = $factory->CreateAreaRule( '800 to 1600',

       'SQFT &gt;= 800 AND SQFT &lt; 1600',  'FFFFBF20');

     $areaRule3 = $factory->CreateAreaRule('1600 to 2400',

       'SQFT &gt;= 1600 AND SQFT &lt; 2400', 'FFFF8040');

     // Create an area type style.

     $areaTypeStyle = $factory->CreateAreaTypeStyle(

       $areaRule1 . $areaRule2 . $areaRule3);

     // Create a scale range.

     $minScale = '0';

     $maxScale = '1000000000000';

     $areaScaleRange = $factory->CreateScaleRange(

       $minScale, $maxScale, $areaTypeStyle);

     // Create the layer definiton.

     $featureClass = 'Library://Samples/Sheboygan/Data/'

     .  'Parcels.FeatureSource';

     $featureName = 'SHP_Schema:Parcels';

     $geometry = 'SHPGEOM';

     $layerDefinition = $factory->CreateLayerDefinition(

       $featureClass, $featureName, $geometry,

       $areaScaleRange);

     //---------------------------------------------------//

     // ...

The script then saves the XML to a resource and loads that resource into the map. See Adding Layers To A Map.