Initializes a new ServiceLayer object and connects the layer to an ArcGIS Server 2D map service using the specified URL.

Namespace:  ESRI.ArcGISExplorer.Mapping

Assembly:  ESRI.ArcGISExplorer (in ESRI.ArcGISExplorer.dll) Version: 2.0.0.1500 (2.0.0.1500)

Syntax

C#
public static ServiceLayer OpenMapServer(
	Uri url
)
Visual Basic (Declaration)
Public Shared Function OpenMapServer ( _
	url As Uri _
) As ServiceLayer

Parameters

url
Type: System..::.Uri

A Uri object which represents a Uniform Resource Identifier and consists of a string used to fully identify the map service on the Internet, including the map service name .

Return Value

A ServiceLayer object connected to the specified ArcGIS Server 2D map service.

Remarks

This method is functionally equivalent to the OpenMapServer(Uri, String) method. They are provided to allow you use your preferred style for connecting to map services.

Use this method to both instantiate a ServiceLayer and connect the layer to an ArcGIS Server 2D map service. In contrast to the Connect method, an exception will be thrown if the specified service cannot be accessed.

Examples

The code below demonstrates how to both create and connect a ServiceLayer in a single call using the static OpenMapServer method.
CopyC#
{
  try
  {
    //Create and connect to the World_Transportation map service 
    ServiceLayer sl = ServiceLayer.OpenMapServer(new Uri("http://services.arcgisonline.com/arcgis/services/Reference/World_Transportation"));

    //Add layer to the map
    ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay.Map.ChildItems.Add(sl);
  }
  catch (ESRI.ArcGISExplorer.ConnectionException ex)
  {
    System.Diagnostics.Debug.Print(ex.Message);
  }
}
CopyVB.NET
Try
  'Create and connect to the GeoEye_Imagery_World_2D map service 
  Dim sl As ServiceLayer = ServiceLayer.OpenMapServer(New Uri("http://services.arcgisonline.com/arcgis/services/Reference/World_Transportation"))
  'Add layer to the map
  ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay.Map.ChildItems.Add(sl)
Catch ex As ESRI.ArcGISExplorer.ConnectionException
  System.Diagnostics.Debug.Print(ex.Message)
End Try

Exceptions

ExceptionCondition
ESRI.ArcGISExplorer..::.ConnectionExceptionConnection failed. Check the Message and InnerException properties of the ConnectionException for more information about the reasons for the failure.

See Also