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

MarkerManagers alignment #98

Closed iriina closed 10 years ago

iriina commented 10 years ago

Hi,

I have a strange problem with the alignment of different MarkerManagers (not sure if it is supposed to be like this). For example, if I want to use both the MarkerManager and the CalloutManager, they will not anchor their child views at the same positions. E.g. if I add two identical views, one with addMarker and the other one with addCallout at exactly the same position, they will not be displayed in the same place. Is this how it should work? I've tried debugging but couldn't figure out the cause.

I have attached an image with the current positioning. In this example, the matching 'D' and 'H' POIs, are added one with addCalout and the other with addMarker, but they do not overlap.

Basically, I want to use these scenario when I display a callout window anchored relative to its associated POI. But with this small position difference, the computation of the anchor coordinates would be a little hardcoded.

screen

While this would be "doable" with the current library, my final scope would be to use scalable markers for the POIs (based on the onLayout methods posted here https://github.com/moagrius/TileView/issues/88 (which work very well :) and non-scalable elements for the Callout windows (because usually the Callouts will display an important info message, that has a better visibility if it doesn't scale). For this I would have to add a normal (without scale support) onLayout method in the CalloutManager and the "scalable" onLayout method in the MarkerManager (or maybe in a new custom manager called ScalableMarkerManager). This would work OK, except that I'll have increasing distance (instead of a fixed one) between the POI and the associated Callout while scaling.

Any idea how I can get rid of the alignment difference? Thanks, Irina

moagrius commented 10 years ago

CalloutManager is a direct subclass of MakerManager, with just a couple extra methods: https://github.com/moagrius/TileView/blob/master/src/com/qozix/tileview/markers/CalloutManager.java

They would of course position their children identically. Are you passing anchor values with either the addMarker or addCallout invocations? Here's some info about that: https://github.com/moagrius/TileView/wiki/Anchors

If you look at the TileViewDemo project, you'll see that we're using markers to open callouts, and they are indeed in the same spot. (If you do use the Demo, grab the latest release first, and add it to the /libs folder of the demo workspace)

My guess is that's you're probably using different anchor values (e.g., you set marker anchors earlier with a global call to tileView.setMarkerAnchorPoints, but are not repeating those anchors in addCallout invocations).

iriina commented 10 years ago

Hi,

Thanks for the reply. Indeed, there was a global setMarkerAnchorPoints in the old code that I didn't notice - I was only relying on the ones in the add methods. It works OK now.

Thanks, Irina

moagrius commented 10 years ago

glad you got it worked out