相关疑难解决方法(0)

Android地图在启动活动中加载非常慢/未加载,直到点击它为止

在开始新的地图活动时,地图加载速度非常慢,并且在点击屏幕之前不会开始加载.

布局如下:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context="com.example.android.momintuition.DirectionsActivity">

    <com.google.android.gms.maps.MapView
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:map="http://schemas.android.com/apk/res-auto"
        android:id="@+id/mapView"
        android:paddingTop="62px"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clickable="true"
        map:uiCompass="true"
        map:zOrderOnTop="true"
        map:uiZoomControls="true"
        android:background="#00000000" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

新活动如下所示:

public class DirectionsActivity extends AppCompatActivity implements OnMapReadyCallback {


    GoogleMap mMap; // Might be null if Google Play services APK is not available.

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_directions);
        MapView mv = (MapView) findViewById(R.id.mapView);
        mv.onCreate(savedInstanceState);
        mMap = mv.getMapAsync(this);

    }

    @Override
    public void onMapReady(GoogleMap googleMap) {
         this.map = googleMap;
         CameraUpdate cameraUpdate =
                                CameraUpdateFactory.newLatLngZoom(new …
Run Code Online (Sandbox Code Playgroud)

android google-maps

10
推荐指数
2
解决办法
4780
查看次数

标签 统计

android ×1

google-maps ×1