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;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

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(R.id.zoomview);
mapView = (MapView) findViewById(R.id.mapview);
mZoom = (ZoomControls) mapView.getZoomControls();
//aggiungo cosa fanno i controlli di zoom alla mappa
linearLayout.addView(mZoom);


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
itemizedOverlay.addOverlay(overlayitem);


//stampa sulla mappa i marker
mapOverlays.add(itemizedOverlay);


MapController mc = mapView.getController();
mc.animateTo(point);
mc.setZoom(10);


}

@Override
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>();




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


}

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


@Override
public int size() {
return mOverlays.size();
}

}

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

Top

Return to Map Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest