Search code examples
androidmapsoverlayprojection

how to know where to draw on the map? (Android)


I'm trying to draw something on a map using overlays. So I have the coordinates of the places I want to draw. I start my map on a certain long/latitude, and I draw using regular screen points like (1,1), (2,3) and so on. But what if the map changes? How can make prevent my drawing from "breaking"? So, to simplify and ilustrate. Lets say that I'm drawing rectangles on the screen. My rectangle has 20px/30px (sides). Do I draw the first one in (0,0). The next one could be (21,0), and the next one (0,31). So, if I slide the screen a bit to the side, how do can I make sure that I'll draw like a forth rectangle in (21,31) relative the way my screen was before.

thank you so much!


Solution

  • You need to associate lat, longs with the corners of your rectangle if you want them to appear at a particular location. It might be easier to do this using Maps APIs Poly line.