Closed GoogleCodeExporter closed 8 years ago
Doesn't work for me either.
Is there a workaround or another way on how to execute methods for each marker?
Original comment by reinhard...@gmail.com
on 9 Aug 2011 at 9:26
Same here. Just ported an app from Google Maps to osmdroid, and the onTap
doesn't work. I use it a lot on driving directions, to tap on the turn markers
to get some text info in a popup window.
In my original code, I'm using the @Override annotation in the onTap method. In
osmdroid, I can't. That method doesn't exist.
Original comment by rui.mtd....@gmail.com
on 18 Aug 2011 at 2:35
doesntr work for me teither
Original comment by azq...@gmail.com
on 27 Aug 2011 at 8:51
Hi. I've the same issue. anybody knows how to solve it?
Original comment by zero...@gmail.com
on 11 Sep 2011 at 6:23
[deleted comment]
I have the same problem with that. I think they change one method by the other
one (onSnapToItem by onTap).
Original comment by javi.xanxez@gmail.com
on 25 Oct 2011 at 9:54
Why it says:
@Override
public boolean onSnapToItem(int pX, int pY, Point pSnapPoint, MapView pMapView) {
// TODO Implement this!
return false;
}
TODO?
Original comment by kako1...@gmail.com
on 27 Oct 2011 at 9:16
'up' !
I'm porting an application that uses an old snapshot of osmdroid, and it tries
to override onTap() in an ItemizedOverlay<> class. But since r417
(http://code.google.com/p/osmdroid/source/detail?spec=svn417&r=417 ), this
method has been removed.
It is still documented in 4.0 docs of Android API:
http://code.google.com/android/add-ons/google-apis/reference/com/google/android/
maps/ItemizedOverlay.html
Is this a bug ? Maybe there is a known workaround on how to get the same
behavior, but I could not find it after searching different
forums/groups/source code.
Any help very appreciated :)
Original comment by marc.pou...@gmail.com
on 20 Feb 2012 at 12:15
Has anyone solved this?
Original comment by jyee.dis...@onescreen.com
on 2 May 2012 at 10:44
Hi,
I also got this problem some weeks ago... Finally, I solved it using
ItemizedOverlayWithFocus class and its onItemSingleTapUp method.
Original comment by 90.se...@gmail.com
on 2 May 2012 at 10:58
sergi, can you post an example of using ItemizedOverlayWithFocus within a
class? Thanks!
Original comment by siile...@gmail.com
on 9 May 2012 at 3:01
I encountered exactly the same issue. And this is probably the only real issue
when porting an app from GoogleAPI to osmdroid. So solutions should be
documented well. Here is my modest contribution.
First of all, look at ItemizedIconOverlay, as it does most of what we want.
After struggling a lot trying to sub-class ItemizedIconOverlay with my custom
onSingleTapUpHelper, I finally made a class containing ItemizedIconOverlay.
Applied to your implementation, it looks like this:
public class MyOwnItemizedOverlay {
protected ItemizedIconOverlay<OverlayItem> mOverlay;
protected Context mContext;
protected Drawable mMarker;
public MyOwnItemizedOverlay(Drawable marker, Context context) {
mContext = context;
ArrayList<OverlayItem> items = new ArrayList<OverlayItem>();
ResourceProxy resourceProxy = (ResourceProxy) new DefaultResourceProxyImpl(mContext);
mMarker = marker;
mOverlay = new ItemizedIconOverlay<OverlayItem>(
items, mMarker,
new ItemizedIconOverlay.OnItemGestureListener<OverlayItem>() {
@Override public boolean onItemSingleTapUp(final int index, final OverlayItem item) {
return onSingleTapUpHelper(index, item);
}
@Override public boolean onItemLongPress(final int index, final OverlayItem item) {
return true;
}
}, resourceProxy);
}
public boolean onSingleTapUpHelper(int i, OverlayItem item) {
//Toast.makeText(mContext, "Item " + i + " has been tapped!", Toast.LENGTH_SHORT).show();
AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
dialog.setTitle(item.getTitle());
dialog.setMessage(item.getSnippet());
dialog.show();
return true;
}
public void addItem(OverlayItem item){
mOverlay.addItem(item);
}
public ItemizedIconOverlay<OverlayItem> getOverlay(){
return mOverlay;
}
}
Using this class is nearly identical to using a sub-class of ItemizedOverlay
(as you did in your MapActivity), except that adding the overlay to the map is
done this way:
mapView.getOverlays().add(itemizedoverlay.getOverlay());
Note that you can also easily implement onItemLongPress, if desired.
Original comment by www.trad...@free.fr
on 16 May 2012 at 2:32
Thanks man, that worked out just awesomely! :)
Original comment by siile...@gmail.com
on 17 May 2012 at 2:12
See also issue 343
Original comment by neilboyd
on 17 May 2012 at 2:18
[deleted comment]
Guys,
Find below a very simple and "regular" implementation, as MyOwnItemizedOverlay
is now a "true" overlay.
class MyOwnItemizedOverlay extends ItemizedIconOverlay<OverlayItem> {
protected Context mContext;
public MyItemizedOverlay(final Context context, final List<OverlayItem> aList) {
super(context, aList, new OnItemGestureListener<OverlayItem>() {
@Override public boolean onItemSingleTapUp(final int index, final OverlayItem item) {
return false;
}
@Override public boolean onItemLongPress(final int index, final OverlayItem item) {
return false;
}
} );
mContext = context;
}
@Override protected boolean onSingleTapUpHelper(final int index, final OverlayItem item, final MapView mapView) {
//Toast.makeText(mContext, "Item " + index + " has been tapped!", Toast.LENGTH_SHORT).show();
AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
dialog.setTitle(item.getTitle());
dialog.setMessage(item.getSnippet());
dialog.show();
return true;
}
}
And to use it in your activity:
ArrayList<OverlayItem> list = new ArrayList<OverlayItem>();
MyOwnItemizedOverlay<OverlayItem> overlay = new MyOwnItemizedOverlay(this,
list);
mapView.getOverlays.add(overlay);
Original comment by mathieu....@gmail.com
on 23 Jun 2012 at 8:30
[deleted comment]
Thanks for sharing matheu. The constructor name is wrong in comment 16 above,
it should be public MyOwnItemizedOverlay(...)
Original comment by carlos...@gmail.com
on 21 Aug 2012 at 4:36
[deleted comment]
This issue should be closed. We have a samples app that covers handling item
clicks.
If there is any issue here it is that we aren't implementing an onTap() method
as the Google Maps API does (how did that happen?).
Original comment by kurtzm...@gmail.com
on 25 Jan 2013 at 7:59
Issue 343 has been merged into this issue.
Original comment by kurtzm...@gmail.com
on 25 Jan 2013 at 7:59
Issue 225 has been merged into this issue.
Original comment by kurtzm...@gmail.com
on 12 Apr 2013 at 3:33
In r1209 we have added onTap and OnFocusChangedListenerSupport.
Original comment by kurtzm...@gmail.com
on 12 Apr 2013 at 3:39
Hi kurtzmarc,
If we want to catch a tap event at an overlay, what's the difference between
new way with ItemizedOverlay's onTap and old way with ItemizedIconOverlay's
onSingleTapUpHelper ?
Personally I extend ItemizedIconOverlay and use helper methods for both single
tap and long press.
Now we can catch the tap event with 2 ways?
Thanks
Original comment by devemu...@gmail.com
on 12 Apr 2013 at 7:30
ItemizedIconOverlay is a concrete implementation of the ItemizedOverlay - it
really belongs in the samples app because it's more of an example of how you
can implement ItemizedOverlay. It could probably be rewritten to take advantage
of onTap().
It's up to you which one you use. It looks like the ItemizedIconOverlay does
not take the "hotspot" into account, so you may have better results with
onTap().
Original comment by kurtzm...@gmail.com
on 12 Apr 2013 at 11:47
Original issue reported on code.google.com by
erezbars...@gmail.com
on 27 Jul 2011 at 9:17