How to scale icons by zoom in a MKMapView? - iphone

How can I have the size of my icons scale with zoom in a MKMapView? As far as I can tell there is no way to do this?
The only thing I can think of is to have the MKMapView a subview of some UIView, and catch all of the user input in this parent view, scale the images on zoom and relay to the subview.

You need to do a CGTransform on the annotation views on each mapRegionChanged

Related

How to resize the custom annotation pin image in MKMapView?

I am using swift 4. I have added MKMapView with some pins but I need to resize the pin image based on the map zooming.
So if anyone knows, how to resize the image based on map zooming?
You can't. Pins always say a constant size as the user zooms the map.
You'll want to look into using a MKOverlay and possibly a custom MKOverlayRenderer subclass. That will allow you to draw content that grows and shrinks as the user zooms in and out.

UIScrollView is Zooming but every thing on scrollview is also zooming?

I am using a scrollview and I am zooming my scrollview.
I want that if i zoom my scrollview only background imageview which in the Scrollview can zoom and a small image on scrollview should not zoom.
Consider a map , if i am zooming map the map zooms but a placemark on that map would remain as it is in terms of size and place..
Same thing i want with my scrollview.
Any help please?
you can add the image view on top of the zooming scroll-view. The order in which the sub-views are added will matter here. So, first add the scroll view that zooms and then the image view

adding a UIView on a UIScrollVIew during the zoom mode

i'm trying to place a UIView on a scrollView during its zoomed state. I want the UIView to be seen on the scrollView and also to resize along with it once the scrollView is zoomed out.. i am able to place the UIView on scrollView during the zoomed state. But the UIView is not getting resized after zooming out... Should i apply any transforms here??? can anyone help me in this please... Thank you
You can use a little trick: before zoom is started get the screenshot of the view (with subviews) that you want to zoom. Add that image to the UIImageView add return it via viewForZoomingInScrollView:. So you actually zoom the image of that view and not the one itself.
After zoom ended scale your actual view manually.
You can find out how to get screen shot from my post here

Set the maximum zoom scale on a UIImageView?

Is there a way to set the maximum zoom level on a UIImageView?
I think imageviews don't really have the funcionality to zoom, most likely you'll want to slap down a uiscrollview and then insert the imageview as a subview, at that point you'll be able to set the max/min zoom scale on the scrollview. There is an apple sample code project called scrolling that is pretty simple example of scrollviews and imageviews:
http://developer.apple.com/library/ios/#samplecode/Scrolling/Introduction/Intro.html
hope that helps.
nick

UIScrollView map with pins that stay at a fixed size?

In my app, I have a ScrollView that shows a map(just a jpeg).
On top of the ScrollView, I added some pins(UIImageView)
So far so good.
But when I zoom in, the pins also get larger.
I would like the pins to stay at a fixed size, just like the pins on the google map application on the iPhone.
How do I solve this?
Thanks!
I've been looking into this for a few days and I've come to the conclusion that there is currently no good way to do this.
First, put your pins as a direct subview of the UIScrollView. Now they'll stay the same size, but will move around when you zoom.
In OS version >=3.2 in UIScrollViewDelegate there is -scrollViewDidZoom:, where you can update the pins to the right coords as it scrolls, and this works great. But in 3.1 we're out of luck. I tried having a NSTimer going and updating the coords instead, but it's not performant on the device.
As a fallback what I do is hide the pins when zooming starts (viewForZoomingInScrollView) and when zooming ends (scrollViewDidEndZooming) update their coords and unhide them.
Make a container UIView that is the same size as the map. Add the map to the UIView with autoresizing of flexible width and height. Add all the pins as individual images, each with flexible margins. Use the container as the zooming view.
If the system autoresizeing does not retain the margin ratio then you can implement layoutSubviews in a custom container view.