Question

I exactly followed the MapView Tutorial of google yet it only displays a blank page of google maps. Here's my code.

My Map xml:

<?xml version="1.0" encoding="utf-8"?>
<com.google.android.maps.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:apiKey="API_KEY"
/>

its class:

public class Maps extends MapActivity {

@Override
protected boolean isRouteDisplayed() {
    return false;
}

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);


    MapView mapView = (MapView) findViewById(R.id.mapView);
    mapView.setBuiltInZoomControls(true);

    List<Overlay> mapOverlays = mapView.getOverlays();
    Drawable drawable = this.getResources().getDrawable(R.drawable.logo);
    ItemOverlay itemizedoverlay = new ItemOverlay(drawable, this);

    GeoPoint point = new GeoPoint(19240000,-99120000);
    OverlayItem overlayitem = new OverlayItem(point, "Hola, Mundo!", "I'm in Mexico City!");

    itemizedoverlay.addOverlay(overlayitem);
    mapOverlays.add(itemizedoverlay);

}

}

And finally the itemized overlay class:

public class ItemOverlay extends ItemizedOverlay {

private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
Context mContext;

public ItemOverlay(Drawable defaultMarker, Context context) {
    super(boundCenterBottom(defaultMarker));

    mContext = context;
}

public void addOverlay(OverlayItem overlay) {
    mOverlays.add(overlay);
    populate();
}

@Override
protected OverlayItem createItem(int i) {
  return mOverlays.get(i);
}

@Override
public int size() {
    return mOverlays.size();
}

@Override
protected boolean onTap(int index) {
  OverlayItem item = mOverlays.get(index);
  AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
  dialog.setTitle(item.getTitle());
  dialog.setMessage(item.getSnippet());
  dialog.show();
  return true;
}

}

So this gives the error and only displays the 'logo' on a blank google maps page. Here are also my manifest permissions:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application ... >
    <uses-library android:name="com.google.android.maps"/>
<application />

What am I missing? what could be the problem, thanks in advance By the way, I created an api key on console.developers.google.com for browser applications which has the permission to google maps v3.

Was it helpful?

Solution

It seems that you are using Google Map V1 which obviously deprecated already. You should now switch to Google Map V2 for using the Maps functionality.

As Per Documentation:

Note: Version 1 of the Google Maps Android API has been officially deprecated as of December 3rd, 2012. This means that from March 18th, 2013 you will no longer be able to request an API key for this version. No new features will be added to Google Maps Android API v1. However, apps using v1 will continue to work on devices. Existing and new developers are encouraged to use Google Maps Android API v2.

OTHER TIPS

Download the below url code:

http://wptrafficanalyzer.in/blog/?wpdmact=process&did=MTgxLmhvdGxpbms=

this may help you

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top