Reputation: 2462
I am working on a app where I have to make Map using MKMapView
, but with circular shape?
Any idea about this, any clue would be helpful too.
See in the screen shoot, you will get an idea what I am asking about.
See the Map in circle.
Upvotes: 0
Views: 1379
Reputation: 7226
First, if you do this while using satellite/aerial photographs you will violate the Google Maps Terms of Service.
10 License Restrictions. Except as expressly permitted under the Terms, or unless you have received prior written authorization from Google (or, as applicable, from the provider of particular Content), Google's licenses above are subject to your adherence to all of the restrictions below. Except as explicitly permitted in Section 7, you must not (nor may you permit anyone else to):
...
10.7 delete, obscure, or in any manner alter any warning, notice (including but not limited to any copyright or other proprietary rights notice), or link that appears in the Service or the Content;
Any circular MKMapView
will probably obscure the copyright notice that displays with photographs.
We may expect MKMapView
will soon change from using Google data to Apple data, but there will probably be similar text that you must not obscure.
With that out of the way, there are two ways you can make this work:
UIView
subclass with a transparent background, make its drawRect
method draw around a circular hole, and make its pointInside:withEvent:
method return NO
for the same hole. Place one of these views on top of your MKMapView
.CAShapeLayer
with an opaque circle (or any other shape) and make it the mask
of the MKMapView
's own layer
. This will allow the circular map to appear anywhere, but it will still be possible to interact with its invisible corners.Upvotes: 1
Reputation: 27072
Here's a tricky way, but it may be you want to!
Add QuartzCore.framework
#import <QuartzCore/QuartzCore.h>
//make circled shape
[yourMapView.layer setMasksToBounds:YES];
[yourMapView.layer setCornerRadius:160.0]; //here you've to pass width of yourMapView / 2
Excited to see more answers!! :)
Upvotes: 7