The original Google Tutorial is here:
http://developer.android.com/resources/tutorials/views/hello-mapview.html
There is a useful Google Groups post regarding the major bug / confusion with this tutorial:
http://groups.google.com/group/android-beginners/browse_thread/thread/9d175c71b8b6825d
The differences are shown below
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map);
MapView mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
List
Drawable drawable = this.getResources().getDrawable(R.drawable.dot_bar);
DefaultItemizedOverlay itemizedoverlay = new DefaultItemizedOverlay(drawable,this);
GeoPoint point = new GeoPoint(19240000,-99120000);
OverlayItem overlayitem = new OverlayItem(point, "Hola, Mundo!", "I'm in Mexico City!");
itemizedoverlay.addOverlay(overlayitem);
itemizedoverlay.ReadyOverlay();
mapOverlays.add(itemizedoverlay);
}
}
Changing the code in onCreate to supply 'this' as a Context for the ItemizedOverLay is critical, otherwise you will get a NullReferenceException on the mContext field when onTap(int) attempts to create a Alert Dialog.
1 comment:
this was also posted on some forums about 'droids
Post a Comment