1

我正在使用一个名为 ExtendedMapView 的扩展 MapView 类,它将包含沿 MapView 以及 currentLocation。然而,该类导致校准时崩溃。

这是导致崩溃的 MapActivity 类的一部分:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.map);

    map=(ExtendedMapView)findViewById(R.id.map_view);}

ExtendedMapView 类:

package com.sit.augmented_reality.map;

import android.content.Context;
import android.location.Location;

import com.google.android.maps.MapView;

public class ExtendedMapView extends MapView {

private Location currentLocation;

public ExtendedMapView(Context context, String apiKey) {
    super(context, apiKey);
     }

public void setCurrentLocation (Location location)
{
    currentLocation = location;
}

public Location getCurrentLocation ()
{
    return currentLocation;
}

}

布局 XML (map.xml):

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout 
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical" 
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">

<com.sit.augmented_reality.map.ExtendedMapView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:id="@+id/map_view" 
android:apiKey="0zGaDxZvhGnutaf58dLLydh5riLex42FsZ7UKcA" />

</RelativeLayout>
4

0 回答 0