FRAMES | NO FRAMES |
Adds repository layer items to the default map.
Availability: Business Analyst Server 9.3.1 SP1.
bool AddLayersToMap ( AddLayersToMapParameters Parameters );
Parameter | Description |
---|---|
Parameters | Configuration options for the utility. Type AddLayersToMapParameters. |
Variable of type Boolean whose value is always true.
A layer is added to the map under the name specified with the LayerName parameter of its esriLayerItem instance. If this parameter is missing, the name of repository item is used as the layer name.
Layers temporary added to the default map are removed when the Business Analyst Server Map Service restarts.
The example below adds repository layers to the map and then removes them.
NOTE: The signature of the BAServerHelper.AddLayersToMap method is simplified against this method—an array of esriLayerItem instances is passed in parameters instead of AddLayersToMapParameters type.
C# |
// Instantiate the BAServerHelper class to access analysis methods BAServerHelper baServerHelper = new BAServerHelper(); baServerHelper.ActiveDatasetID = "USA_ESRI"; // Optional parameter baServerHelper.IsFullErrorMessage = true; // Default is false RenderingParameters imageOptions; TaskOutputType[] outputOptions; esriFolderItem outputReport; // ========= STEP 1: Create a store layer in the repository // Create a PointRecord array of 1 store location. PointRecord[] storePoints = new PointRecord[1]; storePoints[0] = new PointRecord(); storePoints[0].Name = "storePoint"; storePoints[0].Description = "Ring Center"; storePoints[0].StoreID = "1"; storePoints[0].Latitude = 34.057596; storePoints[0].Longitude = -117.195683; CustomerStoreSetupByCoordinatesParameters storeSetupParameters = new CustomerStoreSetupByCoordinatesParameters(); // Set specific analysis parameters storeSetupParameters.GeocodeCustomers = false; storeSetupParameters.NameField = "Name"; storeSetupParameters.Points = storePoints; storeSetupParameters.StoreIDField = "STORE_ID"; // Set other parameters imageOptions = null; outputOptions = new TaskOutputType[0]; // Empty output! // In general, a non-null esriFolderItem is specified to save a newly-created // item to the server-side repository or to reference an existing item in it. esriFolderItem storeLayerItem = new esriFolderItem(); storeLayerItem.folderType = esriFolderType.esriFolderStoreLayers; storeLayerItem.itemName = "storeLayer_AddLayersToMap"; storeLayerItem.workspaceName = "Default Workspace"; storeLayerItem.projectName = "Default Project"; baServerHelper.CustomerStoreSetupByCoordinates(storeSetupParameters, imageOptions, outputOptions, storeLayerItem); PointLayer storeLayer = new PointLayer(); storeLayer.Item = storeLayerItem; // Use the repository item in this sample // ========= STEP 2: Create simple rings around the store and save the analysis in the repository SimpleRingsParameters simpleRingsParameters = new SimpleRingsParameters(); // Set specific analysis parameters simpleRingsParameters.DistanceUnits = esriUnits.esriMiles; simpleRingsParameters.Radii = new double[] { 1, 3, 5 }; simpleRingsParameters.StoreIDField = "STORE_ID"; simpleRingsParameters.Stores = storeLayer; // Set other parameters imageOptions = null; outputOptions = new TaskOutputType[0]; // Empty output! outputReport = null; // In general, a non-null esriFolderItem is specified to save a newly-created // item to the server-side repository or to reference an existing item in it. esriFolderItem taLayerItem = new esriFolderItem(); taLayerItem.folderType = esriFolderType.esriFolderTradeAreas; taLayerItem.itemName = "simpleRings_AddLayersToMap"; taLayerItem.projectName = "Default Project"; taLayerItem.workspaceName = "Default Workspace"; baServerHelper.SimpleRings(simpleRingsParameters, imageOptions, outputOptions, taLayerItem, outputReport); // ========= STEP 3: Add the store layer and analysis results to the default map and then remove them esriLayerItem[] layers = new esriLayerItem[2]; layers[0] = new esriLayerItem(); layers[0].LayerItem = taLayerItem; layers[0].LayerTransparency = 50; layers[0].LayerName = "MySimpleRings"; layers[1] = new esriLayerItem(); layers[1].LayerItem = storeLayerItem; layers[1].LayerTransparency = 50; layers[1].LayerName = "MyStoreLayer"; baServerHelper.AddLayersToMap(layers); bool removed = baServerHelper.RemoveLayersFromMap(new string[] { "MySimpleRings", "MyStoreLayer" }); |