0

我变得疯狂,因为我必须从 gps 获得我的位置,通过mMyLocationOverlay.getMyLocation()从 a ListActivityAND NOT获得MapActivityGetMyLocation想要我没有的上下文和地图视图。我试图采取 a但我在构造函数mapActivity上运行时出错。我发布了错误的代码:" Caused by: java.lang.IllegalArgumentException: mapView == null "MyLocationOverlay()

public class ListDeals extends ListActivity
{   

private Events[] events;  
private MyLocationOverlay mMyLocationOverlay;//Riferimento al MyLocationOverlay
private GeoPoint myPoint = null;

@Override
public void onCreate(Bundle savedInstanceState) 
{
  super.onCreate(savedInstanceState);
  String type = this.getIntent().getStringExtra("type"); //legge cosa c'era scritto nell'intent per avere il dato necessario per fare la query al db

  setContentView(R.layout.list_view_x_deals);
  MapView mMapView = (MapView) findViewById(R.id.mapview);
  mMyLocationOverlay = new MyLocationOverlay(this, MyMapView.mapView);
  myPoint = mMyLocationOverlay.getMyLocation();

MyMapView.mapView 是在我的 MapActivity 中创建的“最终 MapView”。

我哪里错了?

4

1 回答 1

1

如果你MapView没有MapView. 使用常规 GPS api获取 aLocation并将其转换为 aGeoPoint如果您希望它采用该格式。

于 2012-04-23T22:11:25.643 回答