The MapLayer.AddAsync method adds a map or imagery layer to the current drawing using the specified service properties. The layer will use the current coordinate system of the drawing to which it was added. If the layer is added to a drawing containing no coordinate system, the drawing will inherit it from the layer. This method returns the index number of the added layer, which is used to identify the map or imagery layer in other methods such as MapLayer.Get.
Declaration
public async Task<int?> Esri.ArcGISForAutoCAD.MapLayer.AddAsync(Document doc, string url, int transparency = 30)
Parameters
| Type | Name | Description | Required |
|---|---|---|---|
Document | doc | The AutoCAD document to act on. | required |
string | url | A valid path to an ArcGIS map or imagery layer. | required |
int | transparency | The percentage of image transparency to apply to the map (values are 0-99: zero is opaque). | optional (the default is 30) |
Returns
| Type | Description |
|---|---|
int? | The index number of the new map or imagery layer. |
Remarks on error conditions
This method may throw an exception or return null if a parameter is invalid.
Example
Add the map layer from the given URL with 70 percent transparency, and print its index number.// Initialize
var doc = Application.DocumentManager.MdiActiveDocument;
var url = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Water_Network/MapServer";
// Add the map layer
var mapLayerId = await Esri.ArcGISForAutoCAD.MapLayer.AddAsync(doc, url, 70);
// Print the index number of the map layer
doc.Editor.WriteMessage(mapLayerId.ToString());
/* Example output
1
*/
See also
MapLayer.Set—A .NET method that modifies the properties of an existing map or image layer in the drawing with the specified service properties.
esri_maplayer_add—An AutoLISP function that adds a map or imagery layer to the current drawing using the specified service properties.
esri_maplayer_addasync—An AutoLISP function that adds a map or imagery layer to the current drawing using the specified service properties asynchronously.