Select to view content in your preferred language

Add a BingMapsLayer

2354
9
Jump to solution
01-12-2012 03:30 AM
PeterGlenewinkel
Occasional Contributor
Hi!

I have got a problem with adding a BingMapsLayer to my MapView! I have studied the documentation of the api and
i looked at the sample application. I also registered a bing maps key at the bingmapsportal for mobil use.

But I can not run the sample application and my application because there is always the same error:

[ATTACH=CONFIG]11119[/ATTACH]

I don't know how to set these usercredentials or how to tell bingmaps the right settings!
Can anyone help me ?

Thanks for your answers!
0 Kudos
1 Solution

Accepted Solutions
PeterGlenewinkel
Occasional Contributor
I got it working now! 🙂

My failure was to think that as it is written in the
android api for arcgis the brackets have to be around the bingkey:
FROM THE DOCUMENTATION:

The following are examples of how you can work with the BingMapsLayer class. The code will add a map with a Bing Maps Layer of Aerial style.
Java usage:
MapView mv = new MapView(this);
mv.addLayer(new BingMapsLayer(
"[your Bing Maps key]", MapStyle.Aerial));
setContentView(mv);

To initialize a Bing map in a WebMap please see the class description of the MapView.

After the initialization of the bingmapslayer i had to call .getBingLogo();
because if I don't do that i get a android strict mode error because getBingLogo()
is called in the ui-thread.

Thanks for the help!

View solution in original post

0 Kudos
9 Replies
wannachaissawatae
Deactivated User
bingMapLayer = new BingMapsLayer("???", MapStyle.Aerial);

??? is Bing_key
0 Kudos
PeterGlenewinkel
Occasional Contributor
I am using Android Fragments:

public class Map extends Fragment {
...

@Override
public void onActivityCreated(Bundle savedInstanceState) {
  super.onActivityCreated(savedInstanceState);
  MapView _map = (MapView)getActivity().findViewById(R.id.map);
                _map.addLayer(new BingMapsLayer("BingMapsKey", MapStyle.Road));
}


...
}

This is my class very shortened!
If I do it this way all my other layers are working without any problems!
0 Kudos
SebastianGreifeneder1
Occasional Contributor
Are you really using the string "BingMapsKey"? Or did you just replace your real key since you don't want to publish it in the forum?
0 Kudos
PeterGlenewinkel
Occasional Contributor
of course i do not use the string "Bingmapskey" 🙂 i just don't wanted to show the world my id!
0 Kudos
SebastianGreifeneder1
Occasional Contributor
I just wanted to be sure 🙂

Try your app with this key (I use it, and I don't have any problems with Bing maps):
AqTGBsziZHIJYYxgivLBf0hVdrAk9mWO5cQcb8Yux8sW5M8c8opEC2lZqKR1ZZXf

Does the AddBingMap sample work for you with your key, respectively with this key?
0 Kudos
IvanBespalov
Frequent Contributor
0 Kudos
PeterGlenewinkel
Occasional Contributor
I got it working now! 🙂

My failure was to think that as it is written in the
android api for arcgis the brackets have to be around the bingkey:
FROM THE DOCUMENTATION:

The following are examples of how you can work with the BingMapsLayer class. The code will add a map with a Bing Maps Layer of Aerial style.
Java usage:
MapView mv = new MapView(this);
mv.addLayer(new BingMapsLayer(
"[your Bing Maps key]", MapStyle.Aerial));
setContentView(mv);

To initialize a Bing map in a WebMap please see the class description of the MapView.

After the initialization of the bingmapslayer i had to call .getBingLogo();
because if I don't do that i get a android strict mode error because getBingLogo()
is called in the ui-thread.

Thanks for the help!
0 Kudos
EnriqueIbarra
Deactivated User
I got it working now! 🙂  

My failure was to think that as it is written in the  
android api for arcgis the brackets have to be around the bingkey: 
FROM THE DOCUMENTATION: 

The following are examples of how you can work with the BingMapsLayer class. The code will add a map with a Bing Maps Layer of Aerial style.  
Java usage:  
MapView mv = new MapView(this); 
mv.addLayer(new BingMapsLayer( 
[your Bing Maps key  ]", MapStyle.Aerial)); 
setContentView(mv); 
  
To initialize a Bing map in a WebMap please see the class description of the MapView.  

After the initialization of the bingmapslayer i had to call .getBingLogo(); 
because if I don't do that i get a android strict mode error because getBingLogo()  
is called in the ui-thread. 

Thanks for the help!


Hi, could you post your code please! I'm trying to use a bing map but can't do it. I'm using 4.0.3 API and this is what I've done:
BingMapsLayer lyr = new BingMapsLayer("AqTGBsziZHIJYYxgivLBf0hVdrAk9mWO5cQcb8Yux8sW5M8c8opEC2lZqKR1ZZXf", MapStyle.AerialWithLabels);
  map.addLayer(lyr);
0 Kudos
DanO_Neill
Deactivated User
Was the issue exclusive to the implicit brackets from the JavaDoc class description?  We can remove them in the next release.  Let me know if there is/was an issue beyond including the brackets with your Bing Maps Key.
0 Kudos