I couldn't find a way to do this so I wrote my own click logic. This is from a project I've put on ice for now and is work in progress (hard coded values for example) but the logic works. Hope it helps:
@Override
public boolean onTap(GeoPoint geoPoint, MapView mapView){
if (!isRoute){ // nothing to do if it's a route
Cursor cursor = (Cursor) mapView.getTag();
Projection projection = mapView.getProjection();
// get pixels for the point clicked
Point clickedPoint = new Point();
projection.toPixels(geoPoint, clickedPoint);
if (cursor.moveToFirst()){
do {
try {
Double lat = cursor.getFloat(Database.LAT_COLUMN) * 1E6;
Double lng = cursor.getFloat(Database.LONG_COLUMN) * 1E6;
GeoPoint thisGeoPoint = new GeoPoint(lat.intValue(),
lng.intValue());
// get pixels for this point
Point overlayPoint = new Point();
projection.toPixels(thisGeoPoint,overlayPoint);
// did the user click within 30 pixels?
if ((Math.abs(clickedPoint.x - overlayPoint.x) < 30) && (Math.abs(clickedPoint.y - overlayPoint.y) < 30)){
// get a cursor to this record
Cursor thisCursor = TestApp.db.rawQuery("SELECT * FROM " + Database.DATABASE_TABLE_PINS + " WHERE CID='" + cursor.getString(Database.ID_COLUMN) + "'", null);
thisCursor.moveToFirst();
// create and show an instance of the PinDetailsDialog
PinDetailsDialog customiseDialog ;
// TODO this is a kludge, why does this throw an exception sometimes?
try{
customiseDialog = new PinDetailsDialog(mapView, context,thisCursor,context.getResources().getConfiguration().orientation);
customiseDialog.show();
} catch (Exception e){
customiseDialog = new PinDetailsDialog(mapView, mapView.getContext(),thisCursor,context.getResources().getConfiguration().orientation);
customiseDialog.show();
}
return true;
}
} catch (Exception e){
e.printStackTrace();
}
} while(cursor.moveToNext());
}
}
return true;
}
The basic idea is to get the point where the user clicked on the map, convert the point into lat long then iterate my data points looking for a match. Note that I am using a hit test of +/- 30 pixels (which I will not hard code when I pick this up again.
I left the TODO in there just in case you stumble into something similar but I do suspect it's entirely down to a problem somewhere in my PinDetailsDialog class implementation.
I use multiple map views, each of which uses data stored in a SQLite table. I store a reference to a cursor to read the data in the tag property of the Mapview, hence the .getTag() call.