What kind of layer is the Bing Aerial Map

695
2
06-02-2017 10:27 AM
TomFlahive
New Contributor III

I am using ArcObjects in ArcMap to select a Bing aerial layer in the Table of Contents of ArcMap.  I want to find out information about the service, such as the service name and URL.  But I am having trouble figuring out what interface the Bing aerial service implements.  Here is what I have so far:

pLayer = (ILayer)mxDoc.SelectedItem; // Get the selected layer from the ArcMap TOC
IBasemapLayer bmLayer = (IBasemapLayer)pLayer;
ICompositeLayer bmCompositeLayer = (ICompositeLayer)bmLayer;
IBasemapSubLayer bmSubLayer = (IBasemapSubLayer)bmCompositeLayer.get_Layer(0);
ILayer innerLayer = bmSubLayer.Layer;‍‍‍‍‍

But once I get to the actual inner layer of the Bing aerial service, I can't figure out what other interface this implements that might have information such as the URL or service name.  So I basically have two questions:  1. What interface does the Bing aerial service implement that might provide useful information about that service, and 2. Is there an easier way of figuring out what interfaces a layer implements rather than a bunch of "If" statements asking: Is it this interface? No.  Is it this?  No.  Is it this?  No.  It was a real guessing game just getting the few lines of code above.  Thanks.

0 Kudos
2 Replies
DuncanHornby
MVP Notable Contributor

I cannot answer your question about bing maps as that requires some sort of license to view in ArcMap. Below is some VBA code showing you how to access properties of the ESRI imagery basemap.

Public Sub test()
 Dim pmxd As IMxDocument
 Set pmxd = ThisDocument
 Dim pMap As IMap
 Set pMap = pmxd.FocusMap
 Dim pLayer As ILayer
 Set pLayer = pMap.Layer(0)
 Dim pMapServerLayer As IMapServerLayer
 Set pMapServerLayer = pLayer
 Dim pAGSServerObjectName As IAGSServerObjectName
 Dim sLocation As String
 Dim sMapName As String
 pMapServerLayer.GetConnectionInfo pAGSServerObjectName, sLocation, sMapName
 Debug.Print pAGSServerObjectName.Name
 Debug.Print pAGSServerObjectName.URL
End Sub‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

As you can see it is reporting name and URL

0 Kudos
TomFlahive
New Contributor III

Thanks for the reply Duncan, and providing some code.  Unfortunately, the code is not working for Bing layers.  It works for the World Imagery, but not the Bing imagery.  I looked into it some more, but have still not been able to figure out the Bing interface that would give me the URL for Bing layers.

If anyone else has some knowledge of what interface the Bing aerial implements, that would be appreciated.

0 Kudos