Open($userInfo); $resourceService = $siteConnection->CreateService(MgServiceType::ResourceService); // --------------------------------------------------// // Open the map $map = new MgMap($siteConnection); $map->Open($mapName); // ... //---------------------------------------------------// // Create a new layer $factory = new LayerDefinitionFactory(); // Create a line rule. $legendLabel = ''; $filter = ''; $color = 'FF0000FF'; $lineRule = $factory->CreateLineRule( $legendLabel, $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. $featureClass = 'Library://Samples/Sheboygan/Data/' . 'HydrographicLines.FeatureSource'; $featureName = 'SHP_Schema:HydrographicLines'; $geometry = 'SHPGEOM'; $layerDefinition = $factory-> CreateLayerDefinition($featureClass, $featureName, $geometry, $lineScaleRange); //---------------------------------------------------// // ... // Add the layer to the map $newLayer = add_layer_definition_to_map($layerDefinition, "Hydro", "Hydro", $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("Hydro")) { $squareFootageLayer =$layerCollection->GetItem("Hydro"); $squareFootageLayer->SetVisible(true); } //---------------------------------------------------// // Save the map back to the session repository $sessionIdName = "Session:$sessionId//$mapName.Map"; $sessionResourceID = new MgResourceIdentifier($sessionIdName); $sessionResourceID->Validate(); $map->Save($resourceService, $sessionResourceID); //---------------------------------------------------// } catch (MgException $e) { echo " \n"; } ?>