Map and icon with text

Tutorials that use the MapActivity. Many using GPS functionality.

Map and icon with text

Postby bobcat » Wed Apr 22, 2009 9:34 pm

Hi android developers, i'm novice of android i want make an application that when i click on a marker on map i want see an balloon box how make it? I have make a class that insert an icon but i don't know how use it for open ballon my class simplified are:

public class test extends MapActivity {

//variabili per i controlli di zoom e mappa
LinearLayout linearLayout;
MapView mapView;
ZoomControls mZoom;

public void onCreate(Bundle savedInstanceState) {

List<Overlay> mapOverlays;
//variabile per prendere il marker
Drawable drawable;
//oggetto per inserire marker
HelloItemizedOverlay itemizedOverlay;

//prendo i controlli zoom e mappa dal file xml
linearLayout = (LinearLayout) findViewById(;
mapView = (MapView) findViewById(;
mZoom = (ZoomControls) mapView.getZoomControls();
//aggiungo cosa fanno i controlli di zoom alla mappa

GeoPoint point = new GeoPoint( (int) (41.9109* 1E6),(int) (12.4818* 1E6));
mapOverlays = mapView.getOverlays();

drawable = this.getResources().getDrawable(R.drawable.icon);

//istanzio un'oggetto helloItemizedOverlay per visualizzare il marker sulla mappa
itemizedOverlay = new HelloItemizedOverlay(drawable);

//creo le coordinate del marker

OverlayItem overlayitem = new OverlayItem(point, "", "");

//aggiungo i marker all'array di marker

//stampa sulla mappa i marker

MapController mc = mapView.getController();


protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;


public class HelloItemizedOverlay extends ItemizedOverlay {

//array di oggetti da inserire nella mappa
private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();

public HelloItemizedOverlay(Drawable defaultMarker) {
//mi centra la mappa dove si trova il marker


public void addOverlay(OverlayItem overlay) {
//aggiungo l'overlay passato all'array
protected OverlayItem createItem(int i) {
//restituisco l'overlay dell'array in posizione i
return mOverlays.get(i);

public int size() {
return mOverlays.size();


Thanks for your interest.
P.S. I apologize for my English horribbile..
Posts: 6
Joined: Wed Apr 22, 2009 6:45 pm


Return to Map Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest