Borrowing this code from several different tutorials on how to use Google maps on Android, I ran into a problem that “R.drawable.marker cannot be resolved or is not a field”
R.java is not being imported via the known bug in Eclipse.
public void onStart() {
super.onStart();
// Create an ItemizedOverlay to display a list of markers
Drawable defaultMarker = getResources().getDrawable(R.drawable.marker);
HelloItemizedOverlay placesItemizedOverlay = new HelloItemizedOverlay (defaultMarker, this);
GeoPoint point =new GeoPoint((int)(41.856451 * 1E6),
(int)(-87.604864 * 1E6));
OverlayItem overlayitem = new OverlayItem(point, "Line 1", "Line 2");
List<Overlay> mapOverlays = mapView.getOverlays();
placesItemizedOverlay.addOverlay(overlayitem);
mapOverlays.add(placesItemizedOverlay);
// mapView.getOverlays().add(placesItemizedOverlay);
}
You need to have a
marker.png(ormarker.jpegor whatever) file in one or more of thedrawable*directories in your project.