Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle maps shows grey tiles only not map
    text
    copied!<p>I have been working with Google Maps API v2 from the past 4 days but getting failed in displaying Google Maps but display only grey tiles. Eclipse don't show any error while running the app in emulator and on real device( connected to PC as emulator).The API key I have mentioned(<strong>in place of my api key</strong>) is the one I got by displaying the debug certificate fingerprint. Anyone Pls. help! Thanks in advance.</p> <p><strong>manifest file:</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.VertexVerveInc.GPSLocator" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/&gt; &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/&gt; &lt;uses-permission android:name="android.permission.INTERNET"/&gt; &lt;uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" /&gt; &lt;application android:allowBackup="true" android:icon="@drawable/icon" android:label="@string/app_name"&gt; &lt;uses-library android:name="com.google.android.maps"/&gt; &lt;activity android:name="GPSLocatorActivity" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p><strong>main.xml file</strong></p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;com.google.android.maps.MapView android:id="@+id/mapView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:enabled="true" android:clickable="true" android:apiKey="my api key" /&gt; &lt;/LinearLayout&gt; </code></pre> <p><strong>GPSLocatorActivity.java file</strong></p> <pre><code>package com.VertexVerveInc.GPSLocator; import com.google.android.maps.MapActivity; import com.google.android.maps.MapView; import com.google.android.maps.MapController; import com.google.android.maps.GeoPoint; import android.content.Context; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.location.Geocoder; import android.location.Address; import com.google.android.maps.Overlay; import android.graphics.Canvas; import android.graphics.Point; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import java.util.List; import java.util.Locale; import java.io.IOException; import android.os.Bundle; import android.widget.Toast; public class GPSLocatorActivity extends MapActivity { private MapView mapView; private MapController mapController; private LocationManager locationManager; private LocationListener locationListener; @SuppressWarnings( "deprecation" ) @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); locationListener = new GPSLocationListener(); locationManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0, 0, locationListener); mapView = (MapView) findViewById(R.id.mapView); // enable Street view by default mapView.setStreetView(true); // enable to show Satellite view mapView.setSatellite(true); // enable to show Traffic on map mapView.setTraffic(true); mapView.setBuiltInZoomControls(true); mapController = mapView.getController(); mapController.setZoom(16); } @Override protected boolean isRouteDisplayed() { return false; } private class GPSLocationListener implements LocationListener { @Override public void onLocationChanged(Location location) { if (location != null) { GeoPoint point = new GeoPoint( (int) (location.getLatitude() * 1E6), (int) (location.getLongitude() * 1E6)); /* Toast.makeText(getBaseContext(), "Latitude: " + location.getLatitude() + " Longitude: " + location.getLongitude(), Toast.LENGTH_SHORT).show();*/ mapController.animateTo(point); mapController.setZoom(16); // add marker MapOverlay mapOverlay = new MapOverlay(); mapOverlay.setPointToDraw(point); List&lt;Overlay&gt; listOfOverlays = mapView.getOverlays(); listOfOverlays.clear(); listOfOverlays.add(mapOverlay); String address = ConvertPointToLocation(point); Toast.makeText(getBaseContext(), address, Toast.LENGTH_SHORT).show(); mapView.invalidate(); } } public String ConvertPointToLocation(GeoPoint point) { String address = ""; Geocoder geoCoder = new Geocoder( getBaseContext(), Locale.getDefault()); try { List&lt;Address&gt; addresses = geoCoder.getFromLocation( point.getLatitudeE6() / 1E6, point.getLongitudeE6() / 1E6, 1); if (addresses.size() &gt; 0) { for (int index = 0; index &lt; addresses.get(0).getMaxAddressLineIndex(); index++) address += addresses.get(0).getAddressLine(index) + " "; } } catch (IOException e) { e.printStackTrace(); } return address; } @Override public void onProviderDisabled(String provider) { } @Override public void onProviderEnabled(String provider) { } @Override public void onStatusChanged(String provider, int status, Bundle extras) { } } class MapOverlay extends Overlay { private GeoPoint pointToDraw; public void setPointToDraw(GeoPoint point) { pointToDraw = point; } public GeoPoint getPointToDraw() { return pointToDraw; } @Override public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) { super.draw(canvas, mapView, shadow); // convert point to pixels Point screenPts = new Point(); mapView.getProjection().toPixels(pointToDraw, screenPts); // add marker Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.red); canvas.drawBitmap(bmp, screenPts.x, screenPts.y - 24, null); // 24 is the height of image return true; } } </code></pre> <p>}</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload