moagrius / TileView

TileView is a subclass of android.view.ViewGroup that asynchronously displays, pans and zooms tile-based images. Plugins are available for features like markers, hotspots, and path drawing.
MIT License
1.46k stars 337 forks source link

Absolute anchor positions for markers #460

Closed Derpalus closed 6 years ago

Derpalus commented 6 years ago

Hello,

I wonder if there is a way to use absolue anchor positions for markers?

My problem is that I have a marker which is a nine-patch so it changes size. And this works fine with the relative positions as long as the nine-patch changes size symmetrically, but it just so happens that mine doesn't. In my case the ancor point lies 32px in from the left side of the marker, but the marker only changes size in the right half.

Currently I'm solving this by:

LinearLayout marker = new ...;
Point size = new Point();
getWindowManager().getDefaultDisplay().getSize(size);
marker.measure(size.x, size.y);
int width = layout.getMeasuredWidth();
// anchorX = -32.0f / width

but this does not give exactly correct sizes (probably because it's a nine-patch that hasn't been inflated correctly).

moagrius commented 6 years ago

this is actually something i've thought about and have not implemented, and probably won't for v2, but probably will for v3.

honestly, i'd suggest just forking and hacking the core for now, and modifying MarkerLayout.onLayout... v2 isn't going to get a ton of updates anymore, as my efforts will be almost exclusively on v3, so you really don't lose much by forking.

that said, if you want to add it, it should be fairly simple (check out MarkerLayout) and i'd probably accept a well-formatted and reasonably sane PR.

moagrius commented 6 years ago

this is in the latest release