我在布局和api v2键中使用mapview但不显示地图。我的问题是......我可以使用v2
在mapview中键入或者我将不得不使用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>
获得如下输出:
答案 0 :(得分:3)
您使用的地图com.google.android.maps.MapView
是Google Map API的 v1 。不幸的是,它已被正式弃用。
您应该使用版本2的新版Google Maps API
我的问题是......我可以在mapview中使用v2键吗?
地图V1键取决于MD5键(如果我没有记错),而V2依赖于SHA1键。因此,你不能使用它。
我将不得不使用mapfragment
好吧,为什么不呢?
的教程答案 1 :(得分:0)
使用此代码并设置target = Google Inc.:Google API:8
公共类ActivityGoogleMap扩展了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);
}
}