I using class Overlay to marker place on map.. I want show infomation of place when i click icon on map (show atm_name and atm_address).
I tried method onTap but it show all infomation of all icon when i click.
Which method should I use to solved my problem.. Help me.
Sorry i use english not good
My Code:
public class atm_markerATM extends Overlay{
Double lat;
Double lng;
Context ct;
String atm_name;
String atm_address;
@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
Projection projection = mapView.getProjection();
if (shadow == false) {
Double latitude = lat*1E6;
Double longitude = lng*1E6;
GeoPoint geoPoint;
geoPoint = new GeoPoint(latitude.intValue(),longitude.intValue());
// Convert the location to screen pixelats
Point point = new Point();
projection.toPixels(geoPoint, point);
// Setup the paint
Paint paint = new Paint();
Bitmap mBitmap = BitmapFactory.decodeResource(ct.getResources(), R.drawable.hoe);
canvas.drawBitmap(mBitmap, point.x-8, point.y-38, paint);
}
super.draw(canvas, mapView, shadow);
}
@Override
public boolean onTap(GeoPoint point, MapView mapView) {
return false;
}
public void setLocation(Double lat, Double lng, Context ct, String name, String address) {
this.lat = lat;
this.lng = lng;
this.ct = ct;
this.atm_name = name;
this.atm_address = address;
}
}
I’ve used OnTap in my Overlay and it works well.
In my Draw method I populate a ArrayList of objects which represent the displayed entity (ATM in your case). Each of these object has a latitude and longitude value.
In onTap I compare the tapped point with the lat/long of each of the object in my ArrayList (populated during Draw). If the tap hits a point in close proximity to an object then I can display it’s details.
I have some source code which I can post up at some point if this sounds like the way you want to go.
[Edit] Here is the source code which I’ve hacked out the bits you will need. Note that there are some references to bubbleLayouts etc which you won’t need but it’s easier to leave them in.
Note that there is always more than one way to do just about anything – this may not be the best way but it works for me 😉
}