Mapkit drawing a circle - iphone

I would like to do the following using the MapKit in iOS.
I want to place a position on a map and draw a circle around it where the diameter of the circle represents a range. This circle should have a solid color with an alpha of 25%. Much like the circle you get around your own position using google maps when the position is not accurate enough. Deciding how large the circle should be could either be using an extra view or using pinching.
How can I do this?

For the drawing part, couldn't you just draw a square then round it's corners?
#import <Quartz/QuartzCore.h>
-(void)viewDidLoad{
mapRect.cornerRadius = mapRect.frame.size.height/2;//Corner radius = height/2
}
Something like that should get you half way there. I don't know how you're doing the collision detection though.

Related

How do I Convert an OpenLayers Polygon to a Circle?

I have a drawing feature where, as in one case, a person can draw a circle using the methodology in OL docs example. When that's saved, the server needed to be have it converted to a polygon, and I was able to do that using fromCircle.
Now, I'm needing to make the circle modifiable after it's been converted and saved. But I don't see a clear cut way to get a Circle geometry out of the Polygon tools provided in the library. There is a Polygon.circular, but that doesn't sound like what I want.
I'm guessing the only way to do this is to grab the center, and one of the segment points, and figure out the radius manually?
As long as fromCircle used sides set to a multiple of 4 and rotation zero (which are the default) center and radius can be easily obtained to convert back to a circle:
center = ol.extent.getCenter(polygon.getExtent());
radius = ol.extent.getWidth(polygon.getExtent())/2;

How to find radius of drawn shape in MKMapView

I am stuck with an issue,
I have drawn a shape in map view and even get the center coordinate, the thing which is left to be found is the radius from the center coordinate.
if anyone could help me out.
This is the shape I have drawn, the annotation is the center point, Need to find the radius and then draw a circle on it
Here is the image :
The above issue is resolved, now i need to find the difference in space between circle border and polygon border so that when my server returns data i can only show pins on the polygon.
Here is the image :-
https://i.stack.imgur.com/tezWr.png

rotating UILabel roller

I've set out to make a rotating roller uipicker like these. I know how to rotate a UILabel but I need help with the math to know how to progressively rotate the UILabel's based on their position on a circle of x circumference? Any math whizzes out there or am I over-thinking it?
What I'm thinking so far:
I need to find the angle of the tangent of a circle at a particular degree so I know which angle to rotate the label (this shouldn't be hard)
Hard bit will be working out the x/y coordinates and working how how much space to put between each value
EDIT
I'm thinking it might be easier to treat it as a half octagon and I can tweak the angles manually until it looks good. Then the only problem is working out how to animate between the positions but that won't be hard as it is just a rotate/move animation.
Here's a good tutorial on how to implement it.
http://www.raywenderlich.com/9864/how-to-create-a-rotating-wheel-control-with-uikit

I want to transform from rectangle view to curve view in ios

I want to add label in view. Not rectangle label but curve label.
middle point lower with certain rate. Like 'U'. how??
I think using CGContextAddCurveToPoint. but how to use? in ios.
You can't do this with a UILabel, but if you take the string you want to draw into a curve, you can draw each letter and then alter the angle of the drawing using the technique in this related question:
How do I draw an NSString at an angle?
(i.e. change the angle and position after every letter).

CGPath masked off CGPoints

I'm trying to build this:
Where the white background is in fact transparent. I know how to clip a CGPath to a set region, but this seems to be to other way around, since I need to substract regions from a filled CGPath.
I guess the right way to go would be to substract the whole outer-circles from the CGPath and then to draw smaller circles at my CGPoints, but I'm not sure how to execute the former. Can anyone point me in the right direction?
That's what I would do :
1) Draw your general line
2) CGContextSetBlendMode(context, kCGBlendModeClear) to "clear the context" when you draw.
3) Draw you bigger circles
4) CGContextSetBlendMode(context, kCGBlendModeNormal) to return to normal drawing
5) Draw your little circles.
You could instead start a transparency layer, draw the lines, then draw the larger transparent circles using the clear color, then draw the smaller black circles. Then when you finish the transparency layer, it will composite exactly what you want back onto the context.