我想通过谷歌地图检测用户位置并按照谷歌教程进行操作,但是第 6 行的方法(getController)中存在错误,错误详细说明了方法 getController() 对于 MapView 类型未定义
private GoogleMap map;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ogenia);
MapView view = (MapView) findViewById(R.id.map);
final MapController control = view.getController();
LocationManager Manager = (LocationManager) this
.getSystemService(Context.LOCATION_SERVICE);
LocationListener listener = new LocationListener() {
public void onStatusChanged(String provider, int status,
Bundle extras) {
// TODO Auto-generated method stub
}
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
@Override
public void onLocationChanged(Location location) {
control.setCenter(new GeoPoint((int) location.getLatitude(),
(int) location.getLongitude()));
}
};
Manager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
listener);
}
}