mkpolygon

Render Title of MKPolygon

痴心易碎 提交于 2019-12-05 21:17:38
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:@"latitude"] floatValue], [[pointDict valueForKeyPath:@"longitude"] floatValue]); index++; } MKPolygon

Check if user location is inside a shape

可紊 提交于 2019-12-03 21:31:14
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 let polygonPath:CGMutablePathRef = CGPathCreateMutable() // get points of polygon let

MKMapView with multiple overlays memory-issue

元气小坏坏 提交于 2019-11-30 05:46:29
There seems to be an "issue" with overlays and the MapKit . Unlike annotations, overlays aren't reused and therefore when adding multiple overlays would cause memory-problems on a real device. I've had this problem multiple times. So my question is, how can I reuse the MKOverlay and so improve the performance of overlays on MapKit ? The Answer to this is not "reusing" but to draw them all in to one MKOverlayView and then draw that on the map. Multiple MKPolygons , MKOverlays etc. cause heavy memory-usage when drawing on the map. This is due the NOT reusing of overlays by MapKit . As

MKMapView with multiple overlays memory-issue

这一生的挚爱 提交于 2019-11-29 03:54:48
问题 There seems to be an "issue" with overlays and the MapKit . Unlike annotations, overlays aren't reused and therefore when adding multiple overlays would cause memory-problems on a real device. I've had this problem multiple times. So my question is, how can I reuse the MKOverlay and so improve the performance of overlays on MapKit ? 回答1: The Answer to this is not "reusing" but to draw them all in to one MKOverlayView and then draw that on the map. Multiple MKPolygons , MKOverlays etc. cause

iPhone MKMapView - MKPolygon Issues

耗尽温柔 提交于 2019-11-27 22:25:33
I am trying to plot a MKPolygon on a MKMapView in iOS 4.0. I have an NSArray which contains custom objects that include properties for latitude/longitude. I have a code sample below: - (void)viewDidLoad { [super viewDidLoad]; dataController = [[DataController alloc] initWithMockData]; coordinateData = [dataController getCordData]; CLLocationCoordinate2D *coords = NULL; NSUInteger coordsLen = 0; /* How do we actually define an array of CLLocationCoordinate2d? */ MKPolygon *polygon = [MKPolygon polygonWithCoordinates:coords count:coordsLen]; [mapView addOverlay: polygon]; } - (MKOverlayView *

MKPolygon area calculation

我与影子孤独终老i 提交于 2019-11-27 08:57: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) { CLLocationCoordinate2D p1, p2; for (int i = 0; i < coords.count - 1; i++) { p1 = [coords[i] MKCoordinateValue]

iPhone MKMapView - MKPolygon Issues

假如想象 提交于 2019-11-27 04:34:27
问题 I am trying to plot a MKPolygon on a MKMapView in iOS 4.0. I have an NSArray which contains custom objects that include properties for latitude/longitude. I have a code sample below: - (void)viewDidLoad { [super viewDidLoad]; dataController = [[DataController alloc] initWithMockData]; coordinateData = [dataController getCordData]; CLLocationCoordinate2D *coords = NULL; NSUInteger coordsLen = 0; /* How do we actually define an array of CLLocationCoordinate2d? */ MKPolygon *polygon = [MKPolygon