I had the same problem.
i solved it by changing the following:
in HelloGoogleMaps,java:
HelloItemizedOverlay itemizedoverlay = new
HelloItemizedOverlay(drawable);
replace by:
HelloItemizedOverlay itemizedoverlay = new
HelloItemizedOverlay(drawable, this);
and in HelloItemizedOverlay.java change the new constructor with the
boundCenterBottom method to see the marker:
public HelloItemizedOverlay(Drawable defaultMarker, Context
context)
{
super(boundCenterBottom(defaultMarker));
mContext = context;
}
On 24 feb, 16:23, yodaa <[email protected]> wrote:
> Hi,
>
> I followed the Google Map View tutorial located
> at:http://developer.android.com/resources/tutorials/views/hello-mapview....
>
> I'm running Eclipse Galileo (up to date) under Windows XP SP3.
>
> The tutorial projet is runs within the emulator but clicking on one
> of the drawable "androidmarker" positionned on the map leads to the
> following Error message:
>
> Sorry!
> The applications HelloGoogleMaps (process com.tests) has stopped
> unexpectedly. Please try again.
>
> 1 ) File :AndroidManifest.xml :
> ----------------------------------------------------
> <?xml version="1.0" encoding="utf-8"?>
> <manifest xmlns:android="http://schemas.android.com/apk/res/android"
> package="com.tests"
> android:versionCode="1"
> android:versionName="1.0">
> <application android:icon="@drawable/icon" android:label="@string/
> app_name">
> <uses-library android:name="com.google.android.maps" />
> <activity android:name=".HelloGoogleMaps"
> android:label="@string/app_name"
>
> android:theme="@android:style/Theme.NoTitleBar">
> <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.INTERNET" />
> <uses-sdk android:minSdkVersion="7" />
> </manifest>
> 2 ) File : res/layout/main.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="fill_parent"
> android:layout_height="fill_parent"
> android:clickable="true"
> android:apiKey="myapikey..." />
>
> 3 ) File : HelloGoogleMaps.java :
> ----------------------------------------------------
> package com.tests;
>
> import java.util.List;
>
> import android.graphics.drawable.Drawable;
> import android.os.Bundle;
> import com.google.android.maps.GeoPoint;
> import com.google.android.maps.MapActivity;
> import com.google.android.maps.MapView;
> import com.google.android.maps.Overlay;
> import com.google.android.maps.OverlayItem;
>
> public class HelloGoogleMaps extends MapActivity
> {
> /** Called when the activity is first created. */
> @Override
> public void onCreate(Bundle savedInstanceState)
> {
> super.onCreate(savedInstanceState);
> setContentView(R.layout.main);
> MapView mapView = (MapView) findViewById(R.id.mapview);
> mapView.setBuiltInZoomControls(true);
> List<Overlay> mapOverlays = mapView.getOverlays();
> Drawable drawable =
> this.getResources().getDrawable(R.drawable.androidmarker);
> HelloItemizedOverlay itemizedoverlay = new
> HelloItemizedOverlay(drawable);
> GeoPoint point = new GeoPoint(19240000,-99120000);
> OverlayItem overlayitem = new OverlayItem(point, "Hola,
> Mundo!", "I'm in Mexico City!");
> itemizedoverlay.addOverlay(overlayitem);
> mapOverlays.add(itemizedoverlay);
> }
> @Override
> protected boolean isRouteDisplayed()
> {
> return false;
> }
>
> }
>
> 4 ) File : HelloItemizedOverlay.java :
> ----------------------------------------------------
> package com.tests;
>
> import java.util.ArrayList;
> import android.app.AlertDialog;
> import android.content.Context;
> import android.graphics.drawable.Drawable;
> import com.google.android.maps.ItemizedOverlay;
> import com.google.android.maps.OverlayItem;
>
> public class HelloItemizedOverlay extends ItemizedOverlay
> {
> private ArrayList<OverlayItem> mOverlays = new
> ArrayList<OverlayItem>();
> private Context mContext;
> // First constructor
> public HelloItemizedOverlay(Drawable defaultMarker)
> {
> super(boundCenterBottom(defaultMarker));
> }
> // Second constructor
> public HelloItemizedOverlay(Drawable defaultMarker, Context context)
> {
> super(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;
> }
>
> }
>
> I suspect something gone wrong within the "onTap" method of
> "HelloItemizedOverlay"...
>
> Could anyone give me a clue on that?
> Thanks
--
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en