In my app I am showing a Google map with pointer. I have submitted the app in market
and I checked it by downloading from the market.
The map in default is shown in Hybrid view. Normally the map looks good but when I try to zoom in the map shows an empty background as in the following figure
Following is my map code:
class MapOverlay extends com.google.android.maps.Overlay {
public boolean draw(Canvas canvas, MapView mapView,boolean shadow, long when) {
super.draw(canvas, mapView, shadow);
Point screenPts = new Point();
mapView.getProjection().toPixels(p, screenPts);
Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.pin);
canvas.drawBitmap(bmp, screenPts.x, screenPts.y-100, null);
return true;
}
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map);
Map = (ImageButton)findViewById(R.id.MapBtn);
Hybrid = (ImageButton)findViewById(R.id.hybridBtn);
mapView = (MapView) findViewById(R.id.mapView);
mapView.setSatellite(true);
mapController = mapView.getController();
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationManager.getProvider(LocationManager.GPS_PROVIDER);
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
String bestProvider = locationManager.getBestProvider(criteria, true);
p = new GeoPoint((int) (latPt * 1E6),(int) (lngPt * 1E6));
mapController.animateTo(p);
mapController.setZoom(16);
mapView.invalidate();
mapView.setTraffic(true);
mapController = mapView.getController();
MapOverlay mapOverlay = new MapOverlay();
List<Overlay> listOfOverlays = mapView.getOverlays();
listOfOverlays.clear();
listOfOverlays.add(mapOverlay);
}
Manifest:
<manifest xmlns:android="schemas.android.com/apk/res/android";
package="com.app.ig.sap"
android:versionCode="2"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7" />
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>
<uses-feature android:name="android.hardware.camera"/>
<application
android:icon="@drawable/q_icon"
android:theme="@android:style/Theme.Light"
android:label="@string/app_name"
android:debuggable="false">
<uses-library android:name="com.google.android.maps" />
<activity android:name=".SplashScreen">
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.WRITE_CONTACTS"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.FLASHLIGHT"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>
Can anyone explain me why the map looks like this when it gets zoomed?
Siva based on your reply to my comments this is not due to the imagery not being available on Google's servers, but rather to network latency. There is likely a timeout for the image tiles to load--thus with latency you're seeing the gray tiles (as substitutes, which at least is better than a blank screen). You could adapt your code to test the user's connection, and display a message to the user informing them that they have a slow connection and that the map may not render properly.