moagrius / MapView

(Deprecated, prefer https://github.com/moagrius/TileView) Android widget roughly described as a hybrid between com.google.android.maps.MapView and iOS's CATiledLayer
http://moagrius.github.com/MapView/documentation
69 stars 35 forks source link

Callout drawn off screen #55

Closed phil-applegate closed 11 years ago

phil-applegate commented 11 years ago

Hi,

I've implemented a callout very similar to your example. When the callout is positioned near the top of the image held in the MapView parts of the callout will be drawn off the screen and therefore not visible.

In order to solve this, I could add some white space around the image I'm trying to draw but just thought I'd check if there are any better solutions.

Thanks for your work.

moagrius commented 11 years ago

I've had this happen before as well (with both markers and callouts) - in my specific use-case, I just specified a positive anchor point for markers and callouts that would be positioned off screen (and a different image as well, one that pointed up, for example, instead of down, to indicate the actual "point" the marker was indicating).

So while an anchor of -0.5f, -1.0f positions the marker centered above the actual point, you could use -0.5f, 1.0f (notice the lack of the negative sign on the y-axis anchor) to position is centered below the point (this would be appropriate for where a marker was offscreen by being to close to the top border).

Remember that you can specify anchors for individual markers and callouts (like addMarker(View, double, double, float, float) and addCallout(View, double, double, float, float)), that will override the default set by setMarkerAnchorPoints(float, float)

In my case, I had a small number of markers and just hard-coded the ones that would be offscreen with the appropriate anchors, but I can imagine a lot of circumstances where it'd need to be dynamically calculated. There's nothing built-in to handle that directly, but i'd imagine it wouldn't be too tough to implement.

HTH, LMK either way.

phil-applegate commented 11 years ago

Thanks, this all makes sense - I'll look into changing anchor points of the markers, seems more sensible than adding unnecessary whitespace!

Thanks for your help.

moagrius commented 11 years ago

cool. if you're satisfied this'll resolve your issue, feel free to close this thread.