Tileview version 2.0 OnHotSpotTap not working and delayed zooming tileview when drawing with many path point
I have 2 problem here when I'm using the tileview latest library v2.0,
-
I'm using the OnHotSpotTap on the latest tileview v2.0 but nothing come out, even when I use the MarkerTapListener but still nothing come. I wan to click/tab on the tileview and get the point (something like click listener), can you help me with it?
-
I draw the path based on the points I put in, delay is occur and even sometimes the app crash when I zoom the tileview, I have tested on it, if too many point put in the delay will occur. I face this issue in old and latest library as well.
- do you have hotspots defined? can you post the relevant pieces of your code?
Canvas.drawPathis not performant. If you have a lot of points you may need to come up with your own strategy for drawing paths - one user draws the paths directly on the tile bitmaps, for example
I faced same his problems. My code: HotSpot hotSpot = new HotSpot(); hotSpot.setTag(this); ArrayList<double[]> hotpots=new ArrayList<>(); hotpots.add(new double[]{0, 0, 400, 400}); mTileView.addHotSpot(hotpots, new HotSpot.HotSpotTapListener() { @Override public void onHotSpotTap(HotSpot hotSpot, int x, int y) { Activity activity = (Activity) hotSpot.getTag(); Log.d("HotSpotTapped", "With access through the tag API to the Activity " + activity); } });
the hotSpot variable you define on line 1 is never added; instead you're adding a new hot spot (at 0, 0, 400, 400) that has a listener, but no tag.
try the sample in the readme: https://github.com/moagrius/TileView#hotspots
note how the hotspot is defined, and added explicitly - you're using a shortcut that takes a List of positions and creates a new hotspot, with the listener as the second argument.
Hi, moagrius. Thanks for your reply, about the hot spot I wanna ask about the code : HotSpot hotSpot = new HotSpot(); hotSpot.setTag( this ); hotSpot.set( new Rect( 0, 0, 100, 100 ) ); tileView.addHotSpot( hotSpot, new HotSpot.HotSpotTapListener(){ @Override public void OnHotSpotTap( HotSpot hotSpot, int x, int y ) { Activity activity = (Activity) hotSpot.getTag(); Log.d( "HotSpotTapped", "With access through the tag API to the Activity " + activity ); } });
I have try this code but the first parameter (hotSpot) in the code tileView.addHotSpot( hotSpot, new HotSpot.HotSpotTapListener()) the actual parameter is the double list object, but not the HotSpot object.
I'm confuse on it, can you demo the code to get the x & y value with hot spot?
the addHotSpot(java.util.List<double[]> positions, HotSpot.HotSpotTapListener listener) is just a convenience method, that constructs the HotSpot for you and attaches a listener. If you need more specific functionality, ignore this signature, and use only the addHotSpot(HotSpot hotSpot) signature with your own HotSpot construction.
In the example above, it'd look like this:
HotSpot hotSpot = new HotSpot();
hotSpot.setTag( this );
hotSpot.set( new Rect( 0, 0, 100, 100 ) );
hotSpot.setHotSpotTapListener( new HotSpot.HotSpotTapListener(){
@Override
public void OnHotSpotTap( HotSpot hotSpot, int x, int y ) {
Activity activity = (Activity) hotSpot.getTag();
Log.d( "HotSpotTapped", "With access through the tag API to the Activity " + activity );
Log.d( "HotSpotTapped", "x=" + x + ", y=" + y );
}
});
tileView.addHotSpot( hotSpot );
Thanks for your reply. Appreciate your help.