TileView icon indicating copy to clipboard operation
TileView copied to clipboard

Tileview version 2.0 OnHotSpotTap not working and delayed zooming tileview when drawing with many path point

Open FrancisORB opened this issue 11 years ago • 6 comments

I have 2 problem here when I'm using the tileview latest library v2.0,

  1. 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?

  2. 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.

FrancisORB avatar Dec 04 '15 04:12 FrancisORB

  1. do you have hotspots defined? can you post the relevant pieces of your code?
  2. Canvas.drawPath is 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

moagrius avatar Dec 04 '15 16:12 moagrius

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); } });

xuannam2620 avatar Dec 17 '15 22:12 xuannam2620

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.

moagrius avatar Dec 18 '15 01:12 moagrius

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?

FrancisORB avatar Dec 23 '15 07:12 FrancisORB

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 );

moagrius avatar Dec 23 '15 19:12 moagrius

Thanks for your reply. Appreciate your help.

FrancisORB avatar Dec 28 '15 16:12 FrancisORB