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

Polygons as hotspots #47

Closed fcapano closed 11 years ago

fcapano commented 11 years ago

Would it be possible to set a polygon as a hotspot instead of a rectangle?

moagrius commented 11 years ago

No, the hotspot implementation is tightly coupled to the Rect class, and just uses Rect.contains for hit testing.

fcapano commented 11 years ago

I've created a class Poly which should make it really easy to replace the Rect class. It has a constructor which accepts a list of Point vertices and one that accepts a Rect object for compatibility reasons. The methods you have used (equals and contains) are already implemented. I hope it'll be added to this project, as having polygons instead of rectangles can be very useful in many cases. Thanks for the good work!

https://gist.github.com/fcapano/5565052

moagrius commented 11 years ago

I'll check it out - thanks

If I was to include it (probably as an alternative signature, rather than a full replacement so it doesn't break existing API), would attribution in comments be sufficient if it was included in the core package?

fcapano commented 11 years ago

Of course. I also just fixed a small error and updated the gist.

moagrius commented 11 years ago

cool - as soon as i get some time i'll run some tests with the intention of including it in the next release

thanks

moagrius commented 11 years ago

I'd hoped to have your class extend Rect, to keep the API intact and not have to add a new signature, but Rect is final. That said, I do agree that polygons are more useful than Rects, and will include that in the new major upgrade when the project changes name and repo #57. Will close for now, to be taken up then. Thanks for the contribution - I'll credit you in the new project when it's included.