我正在尝试获取“蓝点”我的位置坐标并将其设置为我的初始地图视图加载的中心。但我得到一个空指针异常。
我在这里想念什么?
public class GetLocationActivity extends MapActivity implements OnClickListener {
private MapView location;
private LocationMarker locationMarker;
private MyLocationOverlay locationOverlay;
private GeoPoint destination;
private GeoPoint source;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.location);
location = (MapView) this.findViewById(R.id.location);
location.setBuiltInZoomControls(true);
location.setClickable(true);
location.setLongClickable(true);
location.getController().setZoom(12);
locationMarker = new LocationMarker(this, location, marker,
(ImageView) findViewById(R.id.drag));
location.getOverlays().add(locationMarker);
locationOverlay = new MyLocationOverlay(this, location);
location.getOverlays().add(locationOverlay);
source = locationOverlay.getMyLocation();
location.getController().setCenter(
new GeoPoint(source.getLatitudeE6(), source.getLongitudeE6()));
}
在source.getLatitudeE6()
.