Sunday, February 5, 2012

Android Google MapView Tutorial - FIX

If you're a newbie like me in the Java/Eclipse/Android business, you probably started by doing the tutorials on developers.android.com
For those of you who got to the google maps tutorial, here are a few fixes of the issues you found:

Since we've defined a constructor that takes a context as a parameter
(HelloItemizedOverlay(Drawable defaultMarker, Context context)it would be a shame not to use it, right? They probably intended to call it but forgot to update the code. So replace
HelloItemizedOverlay itemizedoverlay = new HelloItemizedOverlay(drawable);in the HelloGoogleMapsActivity file inside the onCreate method with this
HelloItemizedOverlay itemizedoverlay = new HelloItemizedOverlay(drawable,this);For the next problem, which is not seeing your icon after you made this changes, make sure you redefine your constructor like this replace
public HelloItemizedOverlay(Drawable defaultMarker, Context context) {
       super(defaultMarker);
       mContext = context;
}
with this
public HelloItemizedOverlay(Drawable defaultMarker, Context context) { 
       super(boundCenterBottom(defaultMarker));
       mContext = context; 
}

No comments:

Post a Comment