Use this method to add an ArcGIS Server map service to the Virtual Earth map. This method creates a VETileSourceSpecification based on the map service defined in the input url. It also returns a JSON formatted response with service information.

Namespace:  ESRI.ArcGIS.VE
  (in ArcGISVE.exe)

Syntax

JScript
 function CreateLayer(
	url : string, 
	layerName : string, 
	callback : function, 
	setDefaults : boolean
)

Parameters

url
Type: string
Url of ArcGIS Server REST resource to be used with Virtual Earth. The resource must be set up to match VE's coordinate system (WGS 1984 Web Mercator - 102113) and tiling scheme. See Creating services for more information.
layerName
Type: string
Name to assign to the layer.
callback
Type: function
Function to handle response. This callback function will be passed two arguments: (1) a VETileSourceSpecification object that may be used to add the layer to the VE map, and (2) a JSON-formatted object with information on the ArcGIS Server service.
setDefaults
Type: boolean
(Optional) Set default values of Bounds, MinZoomLevel, and MaxZoomLevel for the new VETileSourceSpecification. Defaults to false.

Remarks

To use this method, create an ArcGISLayerFactory object, then call its CreateLayer method. The CreateLayer method requires as arguments the URL of the map service, a name to use for the layer, and the name of a function in your page that will receive the newly created Virtual Earth layer. In that callback function, add the returned VETileSourceSpecification to the map. You may set properties of the VETileSourceSpecification before adding it to the map. For example, you can set the minimum and maximu zoom levels, so that the ArcGIS Server layer only draws at certain zoom levels. Below is a code sample for adding the map layer. In this example, the layer is added on page load, but you can add the layer at any point in your application.
Copy 
var map = null;

function OnPageLoad() {
   // Create the VE map
   var centerat = new VELatLong(45.50634690108341, -122.67883300781251);
   map = new VEMap('mymap');
   map.LoadMap(centerat,15,VEMapStyle.Aerial ,false);
   // Use ArcGISLayerFactory to create the map layer
   var agisve_services = new ESRI.ArcGIS.VE.ArcGISLayerFactory();
   var tileUrl = "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Portland/ESRI_LandBase_WebMercator/MapServer";
   // Note the reference to the GetMap callback function
   agisve_services.CreateLayer(tileUrl, "Parcels", GetMap);
}

// This function is passed the VETileSourceSpec to actually add the layer.
function GetMap(tileSourceSpec, resourceInfo) {
   tileSourceSpec.MinZoomLevel = 10;
   tileSourceSpec.Opacity=0.35;
   map.AddTileLayer(tileSourceSpec,true);
}

See Also