I am using Google Map API v2
in my application to show Maps.
I have followed all the steps, that is to be followed to enable Google Map in my application.
public class PinLocationOnMapView extends FragmentActivity {
private double mLatitude = 0.0, mLongitude = 0.0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SupportMapFragment fragment = SupportMapFragment.newInstance();
getSupportFragmentManager().beginTransaction()
.add(android.R.id.content, fragment).commit();
}
}
If I use this code, it shows me map, but if I provide my latitude/longitude values, map tiles does not load, and I see only white tiles.
Following is the code written in onCreate() of above class:
if (getIntent().getExtras() != null) {
final Bundle bundle = getIntent().getBundleExtra("LOCATION");
mLatitude = bundle.getDouble("LATITUDE");
mLongitude = bundle.getDouble("LONGITUDE");
} else {
finish();
}
GoogleMapOptions options = new GoogleMapOptions();
LatLng latLng = new LatLng(mLatitude, mLongitude);
CameraPosition cameraPosition;// = new CameraPosition(latLng, 0, 0, 0);
cameraPosition = CameraPosition.fromLatLngZoom(latLng, (float) 14.0);
options.mapType(GoogleMap.MAP_TYPE_SATELLITE).camera(cameraPosition)
.zoomControlsEnabled(true).zoomGesturesEnabled(true);
SupportMapFragment fragment = SupportMapFragment.newInstance(options);
getSupportFragmentManager().beginTransaction()
.add(android.R.id.content, fragment).commit();
Also, I have a list of lat/long values. I want to show them on MapFragment
, how to show multiple markers on MapFragment
?
I tried with MapView
and ItemizedOverlay
, but it didn't work for me. I believe I have correctly created the SHA1
key to get the API
key, because if that was wrong, I could not see map using MapFragment
as well, but I can see that if I don't pass the lat/log value.