【发布时间】:2023-03-31 10:51:01
【问题描述】:
我想在我的 android 应用程序上显示谷歌地图。显示我做了一些这样的基本步骤:
AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
maps.xml
<view android:id="@+id/mv"
class="com.google.android.maps.MapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:clickable="true"
android:apiKey="0cNoErXkpZDlKvCYr_OFj5xZD39-***********"
/>
这可能是映射类、导入和 onCreate 方法
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import android.os.Bundle;
地图类上的 onCreate() 方法
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.maps);
mapView = (MapView)findViewById(R.id.mv);
mapView.setSatellite(false);
mapView.setTraffic(false);
mapView.setBuiltInZoomControls(true);
int maxZoom = mapView.getMaxZoomLevel();
int initZoom = maxZoom-2;
mapControl = mapView.getController();
mapControl.setZoom(initZoom);
latE6 = (int) (lat*1e6);
lonE6 = (int) (lon*1e6);
gp = new GeoPoint(latE6, lonE6);
mapControl.animateTo(gp);
overlayButton = (Button)findViewById(R.id.doOverlay);
但是为什么我的地图没有显示,我只看到没有地图的网格,当我尝试读取 logcat 时,我看到这个黄色错误
Recycling dispatcher android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher@40563470
请帮助我。谢谢老哥
【问题讨论】:
标签: android google-maps android-maps