MKCircle - Stroke Width equivilant to meters - iphone

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.

Related

Is there a way to draw an ellipse around a pin location on OpenStreetMap with Flutter?

I want to make an ellipse around a user's pin location (OpenStreetMap, Flutter) that has a certain height, width, and angle. The height and width should be to scale with the map and not the screen (eg in some unit of distance, like meters). I can draw a circle using the CircleMarker class as that has an argument useRadiusInMeter, but I'm not able to find something similar for drawing an ellipse. I can only find options such as BoxDecoration or CustomPainter but there is no provision for converting to distance units. Is it possible to define an ellipse in terms of the map scale?
For reference, I want something like this:

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

Calculate proper latitudeDelta and longitudeDelta based on radius?

Does anyone know of a mathematical way to calculate the proper latitudeDelta/longitude delta of a MapView region based on search radius? For instance, I give my users the option to search for items within a radius of 5, 10, 25, 50 & 100 miles. I would like the MapView region to accurately reflect that search radius and just show enough "map" to encompass the search radius.
Forget about the latitude and longitude. Just convert from miles to meters and then create an MKCoordinateRegion by calling init(center:latitudinalMeters:longitudinalMeters:), where the latitudinalMeters and longitudinalMeters are twice the radius, and use that, centered at the user's location, to set the map view's region.

Longitude, Latitude to XY coordinate conversion

I want to now how to convert longitude, latitude to its equivalent xy coordinate components in iPhone programming. (I am using only CoreLocation programming, and want to show a point on iPhone screen without any map).
thanks
Well the exact conversion depends on exactly which part of the Earth you want to show, and the stretching along longitude varies according to latitude, at least in Mercator.
That being said, even if you don't want to display an actual MapKit map, it would probably be easiest to create an MKMapView and keep it to one side. If you set the area you want to display appropriately on that (by setting the region property), you can use convertCoordinate:toPointToView: to map from longitude and latitude to a 2d screen location.
Note that MKMapView adjusts the region you set so as to make sense for the viewport its been given (eg, if you gave it a region that was a short fat rectangle, but the view it had was a tall thin rectangle, it'd pick the smallest region that covers the entire short fat rectangle but is the shape of a tall thin rectangle), so don't get confused if you specify a region with the top left being a particular geolocation, but then that geolocation isn't at the exact top left of the view.

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.