views:

373

answers:

1

Hi

I have a UIView with a world map. This is added to a parent UIView, this parent UIView also has two markers build from UIViews. The markers are placed in the center of two arbitrary countries.

Now I find the midpoint between these two markers moves the world map view so that this midpoint is at the center of the screen, I then continue to scale the map so that the rectangle that just encloses the two markers fills out the screen.

Now my question is: how do I find the "new" coordinates for the markers so they appear to not have moved? i.e. they are still situated over the center of the two countries, but the countries have moved and been scaled

If I was to just move the map by some offset, I could apply this offset to my markers, but when I also apply scale to the map, but not the markers, I loose track of my waypoints.

Hope someone can school me in this little piece of geometry or maybe some built in Cocoa magic?

Thank you.

A: 

Just add the markers not as subviews of the parent view, but as subviews of a static view above both the parent and the map. You could also get rid of the parent view, and just have the markers on a view above the map and the map as a sibling of the marker's parent, but behind the marker's parent.

So like this:

  • Parent
    • Markers
  • Map
chpwn
Hi chpwn. Thanks for the input.Maybe Im missing something, but when the map scales and moves and the markers are static. How will I know where to move the markers afterwards?
RickiG
You can probably use the convertPoint: methods on UIView, not sure if I fully understand you.
chpwn