How to find radius of drawn shape in MKMapView - swift

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

Related

Leaflet Draw - Selecting 1 Draw Option then another causes Drawing to drag map instead of shape

When attempting to draw, if you first select Draw Circle then select Draw Rectangle then go to click on the map, instead of beginning the drawing and dragging the shape out, the shape gets an initial placement and the map drags instead. You can do the opposite as well (select Rectangle then Circle then click/drag).
You can see this behavior here: http://leaflet.github.io/Leaflet.draw/docs/examples/full.html
Draw Circle the click/drag works Fine. Draw Rectangle then click/drag works fine. Draw Circle then Draw Rectangle then click/drag causes map to begin dragging instead of shape.
This does not seem to be an issue when going between Circle-Polygon or Rectangle-Polygon, only Circle-Rectangle.
I tried debugging to see if any errors or weird events were being thrown but no such luck.

Inkcanvas Stroke Top,Left,Right,Bottom Location

In inkcanvas I can able to draw the stroke ,where i want to find the location(Top,Left,Right.Bottom) of the stroke.
If the stroke is drawn at the Top of the inkcanvas control,then stroke location is at Top.
How to find this as i am using getBounds() it is not helping me to find the Top location of the drawn Strokes
GetBounds() is working for me. In my case I'm intercepting the InkCanvas StrokeCollected event and doing:
Rect bounds = e.Stroke.GetBounds();
It gives me the top, left, right, and bottom.
If you need the locations of individual points such as the first or last, you can use the StylusPoints property of the collected stroke to access them.

MKCircle - Stroke Width equivilant to meters

I have a MKCircle. I would like to be able to set a stroke width equivilant to meters not points. So that I can draw an overlay with both radius in meters of a stroke width in meters.
I understand that the points to meters relationship changes whenever the map is zoomed. I have a very low annotation count (1) right now so removing and readding it on zoom should be OK if I can figure out a way to calculate the desired stroke width in points for a meter distance at a given map state.
The first thing to consider is whether you really want to do this: the line could wind up being invisibly thin if the user zooms out.
The only way I can see to do it is to create an appropriately-sized MKCoordinateRegion using MKCoordinateRegionMakeWithDistance and then use MKMapView's convertRegion:toRectToView: to convert it to a CGRect, from which you can read out the width/height to calculate the appropriate line width.

Mapkit drawing a circle

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.

Clipping in MKOverlayView:drawMapRect

I'm having an issue with drawing to areas outside of the MKMapRect passed to drawMapRect:mapRect:zoomScale:inContext in my MKOverlayView derived class. I'm trying to draw a triangle for each coordinate in a collection and the problem occurs when the coordinate is near the edge of the MKMapRect. See the below image for an example of the problem.
In the image, the light red boxes indicate the MKMapRect being rendered in each call to drawMapRect. The problem is illustrated in the red circle where, as you can see, only part of the triangle is being rendered. I'm assuming that its being clipped to the MKMapRect, though the documentation for MKOverlayView:drawMapRect makes me think this shouldn't be happening.
From the documentation:
You should also not make assumptions that the view’s frame matches the bounding rectangle of the overlay. The view’s frame is actually bigger than the bounding rectangle to allow you to draw lines for things like roads that might be located directly on the border of that rectangle.
My current solution is to draw objects more than once if they are in a maprect that is slightly larger than then maprect given to drawMapRect but this causes me to draw some things more than needed.
Does anyone know of a way to increase the size of the clipping area in drawMapRect so this isn't an issue? Any other suggestions are also welcome.
I ended up adding a buffer to the rect passed in to drawMapRect:mapRect:zoomScale:inContext and using that to determine which objects to draw. This results in more objects being drawn than needed, but not by much.