Visual Basic (Declaration) | |
---|---|
Public Overrides Function GetTileUrl( _ ByVal level As Integer, _ ByVal row As Integer, _ ByVal col As Integer _ ) As String |
Parameters
- level
- Layer level
- row
- Tile row
- col
- Tile column
C# | ![]() |
---|---|
// This example assumes that a Map, ListBox, and Image controls have been previously added to the application in XAML. // When the user clicks on an item in the Listbox, the Image control will be populated with the appropriate image // tile that corresponds to the Url obtained by the ArcGISTiledMapServiceLayer.GetTileUrl Method. public MainPage() { InitializeComponent(); // Add An ArcGISTiledMapServiceLayer to the Map Control ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer myArcGISTiledMapServiceLayer = new ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer(); myArcGISTiledMapServiceLayer.Url = "http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer"; myArcGISTiledMapServiceLayer.ID = "myArcGISTiledMapServiceLayer"; Map1.Layers.Add(myArcGISTiledMapServiceLayer); // Create the TileLoading Event handler for the ArcGISTiledMapServiceLayer myArcGISTiledMapServiceLayer.TileLoading +=new EventHandler<ESRI.ArcGIS.Client.TiledLayer.TileLoadEventArgs>(myArcGISTiledMapServiceLayer_TileLoading); // Create the SelectionChnaged Event handler for the Listbox1 ListBox1.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(ListBox1_SelectionChanged); } private void myArcGISTiledMapServiceLayer_TileLoading(object sender, ESRI.ArcGIS.Client.TiledLayer.TileLoadEventArgs e) { // This Event will fire for each tile that is loaded in the Map Control. For instance, if it takes 4 tiled images // to render the Map Control completely, then this Event will fire 4 times. As you Zoom In or Pan around to other // geographic areas in the Map, this Event will continue to fire until all of the tiles have been processed. // The e argument of the Event returns a TileLoadEventArgs object. ESRI.ArcGIS.Client.TiledLayer.TileLoadEventArgs myTileLoadEventArgs = e; // Get the Tile's Level, Row, and Column Properties. int myLevel = myTileLoadEventArgs.Level; int myRow = myTileLoadEventArgs.Row; int myColumn = myTileLoadEventArgs.Column; // Generate a string that is comma delimitted with the Level, Row, and Column values and add them to a Listbox. string myString = myLevel.ToString() + "," + myRow.ToString() + "," + myColumn.ToString(); ListBox1.Items.Add(myString); } private void ListBox1_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { // Get the SelectedItem from the Listbox and parse out the Level, Row, and Column arguments necessary to // obtain the Url for a specific tile. string myString = (String)ListBox1.SelectedItem; string[] myParts = myString.Split(','); int mylevel = System.Convert.ToInt32(myParts[0]); int myrow = System.Convert.ToInt32(myParts[1]); int mycol = System.Convert.ToInt32(myParts[2]); // Get the Url for a specific tile. ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer myArcGISTiledMapServiceLayer = (ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer)Map1.Layers["myArcGISTiledMapServiceLayer"]; string myUrl = myArcGISTiledMapServiceLayer.GetTileUrl(mylevel, myrow, mycol); // Set the specific tile's Url as the Image's Source. Uri myUri = new Uri(myUrl); Image1.Source = new System.Windows.Media.Imaging.BitmapImage(myUri); } |
VB.NET | ![]() |
---|---|
' This example assumes that a Map, ListBox, and Image controls have been previously added to the application in XAML. ' When the user clicks on an item in the Listbox, the Image control will be populated with the appropriate image ' tile that corresponds to the Url obtained by the ArcGISTiledMapServiceLayer.GetTileUrl Method. Public Sub New() InitializeComponent() ' Add An ArcGISTiledMapServiceLayer to the Map Control Dim myArcGISTiledMapServiceLayer As New ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer myArcGISTiledMapServiceLayer.Url = "http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" myArcGISTiledMapServiceLayer.ID = "myArcGISTiledMapServiceLayer" Map1.Layers.Add(myArcGISTiledMapServiceLayer) ' Create the TileLoading Event handler for the ArcGISTiledMapServiceLayer AddHandler myArcGISTiledMapServiceLayer.TileLoading, AddressOf myArcGISTiledMapServiceLayer_TileLoading End Sub Private Sub myArcGISTiledMapServiceLayer_TileLoading(ByVal sender As Object, ByVal e As ESRI.ArcGIS.Client.TiledLayer.TileLoadEventArgs) ' This Event will fire for each tile that is loaded in the Map Control. For instance, if it takes 4 tiled images ' to render the Map Control completely, then this Event will fire 4 times. As you Zoom In or Pan around to other ' geographic areas in the Map, this Event will continue to fire until all of the tiles have been processed. ' The e argument of the Event returns a TileLoadEventArgs object. Dim myTileLoadEventArgs As ESRI.ArcGIS.Client.TiledLayer.TileLoadEventArgs = e ' Get the Tile's Level, Row, and Column Properties. Dim myLevel As Integer = myTileLoadEventArgs.Level Dim myRow As Integer = myTileLoadEventArgs.Row Dim myColumn As Integer = myTileLoadEventArgs.Column ' Generate a string that is comma delimitted with the Level, Row, and Column values and add them to a Listbox. Dim myString As String = myLevel.ToString + "," + myRow.ToString + "," + myColumn.ToString ListBox1.Items.Add(myString) End Sub Private Sub ListBox1_SelectionChanged(ByVal sender As Object, ByVal e As System.Windows.Controls.SelectionChangedEventArgs) Handles ListBox1.SelectionChanged ' Get the SelectedItem from the Listbox and parse out the Level, Row, and Column arguments necessary to ' obtain the Url for a specific tile. Dim myString As String = ListBox1.SelectedItem Dim myParts As String() = Split(myString, ",") Dim mylevel As Integer = CInt(myParts(0)) Dim myrow As Integer = CInt(myParts(1)) Dim mycol As Integer = CInt(myParts(2)) ' Get the Url for a specific tile. Dim myArcGISTiledMapServiceLayer As ESRI.ArcGIS.Client.ArcGISTiledMapServiceLayer = Map1.Layers("myArcGISTiledMapServiceLayer") Dim myUrl As String = myArcGISTiledMapServiceLayer.GetTileUrl(mylevel, myrow, mycol) ' Set the specific tile's Url as the Image's Source. Dim myUri As New Uri(myUrl) Image1.Source = New Imaging.BitmapImage(myUri) End Sub |
An ArcGISMapServiceLayer is made up of multiple tiles (or images) that are automatically put together in a mosaic for display in a Map Control. The tiles are pre-generated on an ArcGIS Server and can be accessed individually via a URL. In order to access a specific tile it is required to know the Level, Row, and Column information.
Note: Using Methods are only available in code-behind. You cannot use a Method via XAML.
The following screen shot corresponds to the code examples in this document. The code demonstrates obtaining the ArcGISTiledMapServiceLayer’s Level, Row, and Column information for each tile that has been retrieved for the service. The user then selects a particular tile’s Level, Row, and Column information in the Listbox to display a single tile (or image) in an Image Control.
Target Platforms: Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family