1
votes

i'm trying to develop a kind of custom map.

So I have a scrollview with zooming enabled.

This scrollview has an UIImageView as its subview that represent the map for the user.

I'd like the user to be able to "drop a pin" like in MapKit.

If I add the pin imageView to the map imageview, the pin image will zoom according to the scrollview zoom, which is not what I want.

I'd like to achieve the same result as in the MapKit Mapview.

The pin should move around when the user pan or zoom, but its image should not become smaller or bigger.

There's a simple way to do this without becoming crazy with math speculations over zoomscale and contentoffset?

Thanks a lot, everybody.

2

2 Answers

0
votes

This is more of a guess than anything, but adding the pin's layer as a sublayer of the image view seems like the way to go about doing this.

0
votes

I did it.

All I had to do was add the pin to the map imageview.

After that on the scrollView delegate, i adjusted the pin scale according to the scrollview zoomscale like this:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    _redPin.transform = CGAffineTransformMakeScale(1 / scrollView.zoomScale, 1 / scrollView.zoomScale);
}