views:

355

answers:

2

I am trying to build a map with annotations very much like MKMapKit (google maps API) - but with custom maps for indoors. I have a PDF map (mapView) being loaded into a scroll view for the map as a CATiledLayer - this works great!

I have a view annotationsView which draws the annotation bubble on top of the map exactly how I want it - but positioning this is tricky.

If I add the annotationsView as a subview to the mapView - the annotations are zoomed and scaled with the map - but the position stays exactly where it is placed (good!). Can I stop this view from scaling when the map is pinched etc?

If I add the annotationsView to the uiscrollview then it keeps its scale (good!) but moves diagonally up-left when the map is zoomed - it appears to keep a fixed distance from the top left corner of the scrollviews content and this distance is not scaled as the map is zoomed.

Am I going about this all wrong?

A: 

in -scrollViewDidEndZooming: delegate method you can scale your subviews back to original size. The code will be like:

- (void) scrollViewDidEndZooming: (UIScrollView *) aScrollView withView: (UIView *) view atScale: (float) scale{
   ...
   mySubView.transform = CGAffineTransformMakeScale(1/scale, 1/scale);
   ...
}
Vladimir
A: 

i'm doing something similar... However, i'm wondering: did anyone find a way to maintain scale ratio of "floating" objects WHILE pinching?

Pierre