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 >= 1 AND SQFT < 800', 'FFFFFF00');
$areaRule2 = $factory->CreateAreaRule( '800 to 1600',
'SQFT >= 800 AND SQFT < 1600', 'FFFFBF20');
$areaRule3 = $factory->CreateAreaRule('1600 to 2400',
'SQFT >= 1600 AND SQFT < 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.