Using OnTap (int i) with multiple layers of ItemizedOverlay

I had to show a few (about 600, everything that could be marked to show some information about them) to overlay elements on a mapview. Regarding performance issues, I thought it would be wise to group them into different ItemizedOverlay classes, because each group will show different information about them. (The company's activity is airports, VOR, NDB, etc.).

My problem is that if I separate them into classes and show them, the performance is super. The map flows smoothly. But when I add a second layer on top of the first, the elements on the first layer become invisible.

When I read a lot and debugged using the Log.i method, I realized that each layer gets a click, but only the OnTap method is called (geodata point, MapView mapview). Calling super.onTap (point, mapview) does not work. I need the onTap (int index) method to identify the marker. (I have both methods in my classes (after I read a lot of examples)).

So what should I do? Is there any way to solve my problem? I do not want to go into difficult approaches, such as comparing clicked coordinates to all the coordinates of the overlay elements to find something close.

Thanks in advance.

+4
source share
1 answer

The onTop method (and any other touch event works on android) is that it will ping any objects located in the coordinates until one of onTaps (or any other touch event) returns true. In this case, the onTap method (geometry point, MapView mapview) returns true. This consumes this touch event and does not allow it to be passed to other onTap events. If you make the onTap event false, other onTap events will receive ping. Hope this helps.

+7
source

Source: https://habr.com/ru/post/1415022/


All Articles