I am trying to get the “blue dot” my location coordinates and set it as the center of my initial mapview load. But I am getting a null pointer exception.
What am I missing here ?
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()));
}
Getting a nullPointer at source.getLatitudeE6().
Forgetting my basics here :). I need to get my location using LocationManager.