Reputation: 723
I'm trying to control Google map camera like this
private void setUpMap() {
Log.e(LOG_TAG, "in setup method");
mMap.setMyLocationEnabled(true);
LatLng startingPoint = new LatLng(129.13381, 129.10372);
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(startingPoint, 16));
Log.e(LOG_TAG, "in Setup method" + (mMapFragment == null));
}
LogCat prints
"in setup method"
"in setup method false"
2 log is shown it means mMap.moveCamera(...)
is called
setUpMap()
call from here
private void setUpMapIfNeeded() {
mMapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentByTag(MFragment.TAG);
if (mMapFragment != null) {
mMapFragment.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
setUpMap();
}
});
}
}
Upvotes: 4
Views: 5425
Reputation: 1596
try this: hope it will work.
private void setUpMap() {
Log.e(LOG_TAG, "in setup method");
mMap.setMyLocationEnabled(true);
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(new LatLng(latitude, longitude)).zoom(15).build();
mMap.animateCamera(CameraUpdateFactory
.newCameraPosition(cameraPosition));
Log.e(LOG_TAG, "in Setup method" + (mMapFragment == null));
}
Upvotes: 5
Reputation: 6717
Your coordinates specified at LatLng startingPoint = new LatLng(129.13381, 129.10372);
seems to be a bit off. In more detail, the maximum latitude is 90 degrees, which is the north pole (-90 is the south pole).
The result of this will be that the camera will not move to a position which is invalid.
Try using coordinates from a known location, such as LatLng startingPoint = new LatLng(55.70, 13.19);
which will give you the position of Lund, Sweden.
So basically, revise the latitude and longitude coordinates for your position.
Upvotes: 3