예제 #1
0
파일: draw_line.php 프로젝트: kanbang/Colt
 //---------------------------------------------------//
 $layerExists = DoesLayerExist($layerName, $map);
 if (!$layerExists) {
     // Create a new layer which uses that feature source
     // Create a line rule to stylize the lines
     $ruleLegendLabel = 'Lines Rule';
     $filter = '';
     $color = 'FF0000FF';
     $factory = new LayerDefinitionFactory();
     $lineRule = $factory->CreateLineRule($ruleLegendLabel, $filter, $color);
     // Create a line type style
     $lineTypeStyle = $factory->CreateLineTypeStyle($lineRule);
     // Create a scale range
     $minScale = '0';
     $maxScale = '1000000000000';
     $lineScaleRange = $factory->CreateScaleRange($minScale, $maxScale, $lineTypeStyle);
     // Create the layer definiton
     $featureName = 'SHP_Schema:Lines';
     $geometry = 'SHPGEOM';
     $layerDefinition = $factory->CreateLayerDefinition($featureSourceName, $featureName, $geometry, $lineScaleRange);
     //---------------------------------------------------//
     // Add the layer to the map
     $newLayer = add_layer_definition_to_map($layerDefinition, $layerName, $layerLegendLabel, $sessionId, $resourceService, $map);
     // Add the layer to a layer group
     add_layer_to_group($newLayer, $groupName, $groupLegendLabel, $map);
 }
 // --------------------------------------------------//
 // Turn on the visibility of this layer.
 // (If the layer does not already exist in the map, it will be visible by default when it is added.
 // But if the user has already run this script, he or she may have set the layer to be invisible.)
 $layerCollection = $map->GetLayers();
 $map->Open($mapName);
 // ...
 //---------------------------------------------------//
 // Create a new layer
 $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 = '10000';
 $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);
 //---------------------------------------------------//
 // ...
 // Add the layer to the map
 $newLayer = add_layer_definition_to_map($layerDefinition, "SquareFootage", "Square Footage", $sessionId, $resourceService, $map);
 add_layer_to_group($newLayer, "Analysis", "Analysis", $map);
 //---------------------------------------------------//
 // Turn off the "Recently Built" themed layer (if it exists) so it does not hide this layer.
 $layerCollection = $map->GetLayers();
 if ($layerCollection->Contains("RecentlyBuilt")) {
     $recentlyBuiltLayer = $layerCollection->GetItem("RecentlyBuilt");
예제 #3
0
//  Lesser General Public License for more details.
//
//  You should have received a copy of the GNU Lesser General Public
//  License along with this library; if not, write to the Free Software
//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
//
include "common.php";
include "constants.php";
require_once "layerdefinitionfactory.php";
InitializeWebTier();
//Area Rules
$areaRule = LayerDefinitionFactory::CreateAreaRule("TestArea1", 'SQFT >= 0 AND SQFT < 500', 'FF808080');
$areaRule .= LayerDefinitionFactory::CreateAreaRule("TestArea2", 'SQFT >= 500 AND SQFT < 1500', 'FF800080');
$areaRule .= LayerDefinitionFactory::CreateAreaRule("TestArea3", 'SQFT >= 1500 AND SQFT < 6000', 'FF808000');
$areaTypeStyle = LayerDefinitionFactory::CreateAreaTypeStyle($areaRule);
$scaleRange = LayerDefinitionFactory::CreateScaleRange('0', '1000000000000', $areaTypeStyle);
/*
//Line Rules
$lineRule = LayerDefinitionFactory::CreateLineRule("TestLine1", "", 'FF808000');

$lineTypeStyle = LayerDefinitionFactory::CreateLineTypeStyle($lineRule);

$scaleRange = LayerDefinitionFactory::CreateScaleRange('0', '1000000000000', $lineTypeStyle);
*/
/*
//Point Rules
$markSymbol = LayerDefinitionFactory::CreateMarkSymbol("", "", 5, 5, "FF800000");
$textSymbol = LayerDefinitionFactory::CreateTextSymbol("", "10", "FF808000");

$pointRule = LayerDefinitionFactory::CreatePointRule("TestPoint", "", $textSymbol, $markSymbol);
$pointStyle = LayerDefinitionFactory::CreatePointTypeStyle($pointRule);
 $markSymbol = $factory->CreateMarkSymbol($resourceId, $symbolName, $width, $height, $color);
 // Create a text symbol
 $text = "ID";
 $fontHeight = "12";
 $foregroundColor = 'FF000000';
 $textSymbol = $factory->CreateTextSymbol($text, $fontHeight, $foregroundColor);
 // Create a point rule.
 $legendLabel = 'trees';
 $filter = '';
 $pointRule = $factory->CreatePointRule($legendLabel, $filter, $textSymbol, $markSymbol);
 // Create a point type style.
 $pointTypeStyle = $factory->CreatePointTypeStyle($pointRule);
 // Create a scale range.
 $minScale = '0';
 $maxScale = '1000000000000';
 $pointScaleRange = $factory->CreateScaleRange($minScale, $maxScale, $pointTypeStyle);
 // Create the layer definiton.
 $featureName = 'PointSchema:Points';
 $geometry = 'GEOM';
 $layerDefinition = $factory->CreateLayerDefinition($featureSourceName, $featureName, $geometry, $pointScaleRange);
 //---------------------------------------------------//
 // ...
 // Add the layer to the map
 $newLayer = add_layer_definition_to_map($layerDefinition, "Points", "Points of Interest", $sessionId, $resourceService, $map);
 add_layer_to_group($newLayer, "Analysis", "Analysis", $map);
 // --------------------------------------------------//
 // Turn on the visibility of this layer.
 // (If the layer does not already exist in the map, it will be visible by default when it is added.
 // But if the user has already run this script, he or she may have set the layer to be invisible.)
 $layerCollection = $map->GetLayers();
 if ($layerCollection->Contains("Points")) {