Select to view content in your preferred language

Bing Integration

608
4
11-29-2011 11:30 AM
CoreyStokes
Emerging Contributor
I`m trying to get this code to work but it keeps saying I am missing a reference to BingApp. Any suggestions?

private void MyMap_Loaded(object sender, RoutedEventArgs e)
        {
            // Associate Bing Services token provided as initialization parameter to application with 
            // the Bing tile layers defined in page xaml.  
            foreach (Layer layer in MyMap.Layers)
                if (layer is TileLayer)
                {
                    (layer as TileLayer).Token = (Application.Current as BingApp.App).BingToken;
                    
                }
        }
0 Kudos
4 Replies
DominiqueBroux
Esri Frequent Contributor
ESRI doesn't provide any bing key.

You have to get yours here : https://www.bingmapsportal.com/ and use it in your code.
0 Kudos
CoreyStokes
Emerging Contributor
I already have a key and have included all reference according to the ESRI tutorials.
0 Kudos
DavidAshton
Frequent Contributor
Corey,

DId you figure this out? I'm having the same issue. BingApp is erroring out and it is stating "Type BingApp could not be found you are missing a using directive or assembly reference)?

I'm following the tutorial and have the Bing ref added and my token added to my xaml.

private void Map_Loaded(object sender, RoutedEventArgs e)
        {
            Map.ExtentChanged += Map_ExtentChanged;

            {
                foreach (Layer layer in Map.Layers)
                    if (layer is TileLayer)
                        (layer as TileLayer).Token = (Application.Current as BingApp.App).BingToken;
            }
        }


Thanks
-D
0 Kudos
DominiqueBroux
Esri Frequent Contributor
it keeps saying I am missing a reference to BingApp. Any suggestions?

BingApp is the Esri class that stores the Esri bing key.

You may not reuse the Esri key.
You have to get your own key here : https://www.bingmapsportal.com/ and then use it in your code, i.e.
(layer as TileLayer).Token = "<myBingKey>";
0 Kudos