mkpolygon

check current location is in MkPolygons

爷,独闯天下 提交于 2021-02-10 18:35:46
问题 I am working in an IOS 7 project ,it contains a location checking (current location is in given polygons). I am Using the following code to check the condition Created an array of MKPolygons for(MKPolygon *poly in self.polygonArray) { [self checkTheLocationIsInPolygon:currentLocation polygon:poly]; } - (void)checkTheLocationIsInPolygon:(CLLocation*)aLocation polygon:(MKPolygon*)aPolygon { CLLocationCoordinate2D coordinate = {aLocation.coordinate.latitude, aLocation.coordinate.longitude};

check current location is in MkPolygons

旧街凉风 提交于 2021-02-10 18:28:15
问题 I am working in an IOS 7 project ,it contains a location checking (current location is in given polygons). I am Using the following code to check the condition Created an array of MKPolygons for(MKPolygon *poly in self.polygonArray) { [self checkTheLocationIsInPolygon:currentLocation polygon:poly]; } - (void)checkTheLocationIsInPolygon:(CLLocation*)aLocation polygon:(MKPolygon*)aPolygon { CLLocationCoordinate2D coordinate = {aLocation.coordinate.latitude, aLocation.coordinate.longitude};

Determining if Latitude/Longitude Point is in a MKPolygon within Mapview?

☆樱花仙子☆ 提交于 2020-02-18 05:05:10
问题 At this moment, I am trying to figure out whether a coordinate on a MKMapView is within a MKPolygon drawn out ahead of time with latitudes/longitudes. I am using CGPathContainsPoint to determine whether a coordinate is within the polygon on the map but it always returns false regardless of the coordinate I choose. Can anyone please explain what exactly is going wrong? Below is my code in Swift. class ViewController: UIViewController, MKMapViewDelegate @IBOutlet weak var mapView: MKMapView!

Render Title of MKPolygon

断了今生、忘了曾经 提交于 2020-01-02 07:10:19
问题 I'm trying to render MKPolygon using the following code: NSMutableArray *overlays = [NSMutableArray array]; for (NSDictionary *state in states) { NSArray *points = [state valueForKeyPath:@"point"]; NSInteger numberOfCoordinates = [points count]; CLLocationCoordinate2D *polygonPoints = malloc(numberOfCoordinates * sizeof(CLLocationCoordinate2D)); NSInteger index = 0; for (NSDictionary *pointDict in points) { polygonPoints[index] = CLLocationCoordinate2DMake([[pointDict valueForKeyPath:@

Check if user location is inside a shape

北战南征 提交于 2019-12-21 06:38:16
问题 I made this method to check if an user location is inside a polygon on a map view (mapkit). I pass to the method the current user location (CLLocationCoordinate2D) and return a boolean just to know if the user is in a polygon or not. func userInsidePolygon(userlocation: CLLocationCoordinate2D ) -> Bool{ // get every overlay on the map let o = self.mapView.overlays // loop every overlay on map for overlay in o { // handle only polygon if overlay is MKPolygon{ let polygon:MKPolygon = overlay as

MKPolygon area calculation

霸气de小男生 提交于 2019-12-17 09:49:43
问题 I'm trying to make an area calculation category for MKPolygon. I found some JS code https://github.com/mapbox/geojson-area/blob/master/index.js#L1 with a link to the algorithm: http://trs-new.jpl.nasa.gov/dspace/handle/2014/40409. It says: Here is my code, which gave a wrong result (thousands times more than actual): #define kEarthRadius 6378137 @implementation MKPolygon (AreaCalculation) - (double) area { double area = 0; NSArray *coords = [self coordinates]; if (coords.count > 2) {

how to automatically zoom mapView to show overlay

时光毁灭记忆、已成空白 提交于 2019-12-11 00:25:44
问题 I am able to draw the polygon on mapView however I need to locate the polygon and zoom it manually. Is there a way to do this process automatically like adjust the polygon in centre? I have browsed the internet and read few related articles, most of them are based on polylines and points. Any kind of help will be appreciated, as I am finding for the solution for a while. Thanks in advance. Using the following methods to draw the polygon on mapView : - func drawFence(coordinates: UnsafePointer

MKPolygon - How to determine if a CLLocationCoordinate2D is in a CLLocationCoordinate2D polygon?

假装没事ソ 提交于 2019-12-10 10:45:42
问题 I have the swift code below that draws a polygon and drops an annotation on MKMapView. I am trying to figure out how i could identify if the annotation's coordinate is within the polygon? import UIKit import MapKit class ViewController: UIViewController { @IBOutlet weak var mapView: MKMapView! override func viewDidLoad() { super.viewDidLoad() let initialLocation = CLLocation(latitude: 49.140838, longitude: -123.127886) centerMapOnLocation(initialLocation) addBoundry() var annotation =

Realm Object returning nil (Swift)

久未见 提交于 2019-12-07 06:52:19
问题 I have a custom polygon object so I can save map overlays to Realm. I'm able to create this objects successfully, but when I want to retrieve the var polygon object it returns nil. When I print the polygon object, it prints it out fine, with all the data. This is a sample of what it prints out. CustomPolygon { name = Polygon1; id = p1; polygon = Polygon { coordinates = RLMArray <0x7f928ef36230> ( [0] Coordinate { latitude = -36.914167; longitude = 174.904722; }, [1] Coordinate { latitude =

MKPolygon - How to determine if a CLLocationCoordinate2D is in a CLLocationCoordinate2D polygon?

本小妞迷上赌 提交于 2019-12-06 05:03:31
I have the swift code below that draws a polygon and drops an annotation on MKMapView. I am trying to figure out how i could identify if the annotation's coordinate is within the polygon? import UIKit import MapKit class ViewController: UIViewController { @IBOutlet weak var mapView: MKMapView! override func viewDidLoad() { super.viewDidLoad() let initialLocation = CLLocation(latitude: 49.140838, longitude: -123.127886) centerMapOnLocation(initialLocation) addBoundry() var annotation = MKPointAnnotation() annotation.coordinate = point1 annotation.title = "Roatan" annotation.subtitle = "Honduras