Reputation: 126
I am using mapview in layout and api v2 key but map is not displayed. My question is...Can I use v2
key in mapview or I will have to use mapfragment.
main.xml
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.google.android.maps.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:enabled="true"
android:apiKey="my_apikey" />
</RelativeLayout>
manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.fpa"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name="com.example.fpa.GMapsActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-library android:name="com.google.android.maps" />
</application>
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
getting output as follows:
Upvotes: 1
Views: 5633
Reputation: 7082
use this code ans set the target=Google Inc.:Google APIs:8
public class ActivityGoogleMap extends MapActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//to add zoom in and zoom out default buttons
MapView mapView = (MapView) findViewById(R.id.mapView);
mapView.setBuiltInZoomControls(true);
}
}
Upvotes: 0
Reputation: 12819
The map that you're using com.google.android.maps.MapView
is a v1 of Google Map API. Unfortunately, it is officially deprecated.
You should use the new version of Google Maps API which is Version 2
My question is...Can I use v2 key in mapview?
Maps V1 key depends on MD5 key (If I'm not mistaken) while V2 depends on SHA1 Key. Therefore, you cannot use that.
I will have to use mapfragment
Well, why not?
Here's a tutorial for Google Map V2
Upvotes: 3