Android: when creating a Map I get a blank page. I also have a valid API key and its installation in the manifest. my activity.
relativeLayout = new RelativeLayout(context);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
relativeLayout.setLayoutParams(layoutParams);
GoogleMapOptions googleMapOptions = new GoogleMapOptions();
googleMapOptions.mapType(GoogleMap.MAP_TYPE_NORMAL)
.compassEnabled(false).rotateGesturesEnabled(false)
.tiltGesturesEnabled(false);
googleMapOptions.camera(new CameraPosition(new LatLng(0, 0), 3, 0,
0));
mapView = new MapView(context, googleMapOptions);
mapView.onCreate(new Bundle());
relativeLayout.addView(mapView);
Double[][] latlang = mapData.getLatlang();
marker = new Marker[mapData.getLatlang().length];
for (int i = 0; i < mapData.getLatlang().length; i++) {
this.marker[i] = mapView.getMap()
.addMarker(
new MarkerOptions()
.position(
new LatLng(latlang[i][0],
latlang[i][1]))
.title(" ")
.snippet(" "));
}
source
share