14.01.2013 Views

Developer's Guide - MapGuide Open Source - OSGeo

Developer's Guide - MapGuide Open Source - OSGeo

Developer's Guide - MapGuide Open Source - OSGeo

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

...<br />

/---------------------------------------------------//<br />

$factory = new LayerDefinitionFactory();<br />

/// Create three area rules for three different<br />

// scale ranges.<br />

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

'SQFT &gt;= 1 AND SQFT &lt; 800', 'FFFFFF00');<br />

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

'SQFT &gt;= 800 AND SQFT &lt; 1600', 'FFFFBF20');<br />

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

'SQFT &gt;= 1600 AND SQFT &lt; 2400', 'FFFF8040');<br />

// Create an area type style.<br />

$areaTypeStyle = $factory->CreateAreaTypeStyle(<br />

$areaRule1 . $areaRule2 . $areaRule3);<br />

// Create a scale range.<br />

$minScale = '0';<br />

$maxScale = '1000000000000';<br />

$areaScaleRange = $factory->CreateScaleRange(<br />

$minScale, $maxScale, $areaTypeStyle);<br />

// Create the layer definiton.<br />

$featureClass = 'Library://Samples/Sheboygan/Data/'<br />

. 'Parcels.Feature<strong>Source</strong>';<br />

$featureName = 'SHP_Schema:Parcels';<br />

$geometry = 'SHPGEOM';<br />

$layerDefinition = $factory->CreateLayerDefinition(<br />

$featureClass, $featureName, $geometry,<br />

$areaScaleRange);<br />

//---------------------------------------------------//<br />

// ...<br />

The script then saves the XML to a resource and loads that resource into the<br />

map. See Adding Layers To A Map (page 67).<br />

Example - Using Line Rules<br />

Creating line-based rules is very similar.<br />

64 | Chapter 4 Modifying Maps and Layers

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!