Questions tagged [mkpolygon]

The MKPolygon class (iOS Developer Library) represents a shape consisting of one or more points that define a closed polygon

The MKPolygon class represents a shape consisting of one or more points that define a closed polygon. The points are connected end-to-end in the order they are provided. The first and last points are connected to each other to create the closed shape.

When creating a polygon, you can mask out portions of the polygon by specifying one or more interior polygons. For the polygons you specify, this class uses the even-odd fill rule to determine the final occupied area. When applied to overlapping polygons, this rule can cause specific regions to be masked out (and thereby removed) from the total occupied area.

68 questions
13
votes
1 answer

Prevent MKPolygon to have knots

I'm developing an app with a map in which the user can draw a polygon area. My issue is what it's possible drawing polygons with knots (see the image) (I don't know if knot is the right word). I didn't find a simply way preventing the polygon to get…
Lisarien
  • 1,136
  • 1
  • 12
  • 24
10
votes
3 answers

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

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…
M_Jean
  • 101
  • 1
  • 4
10
votes
3 answers

MKPolygon area calculation

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…
Shmidt
  • 16,436
  • 18
  • 88
  • 136
9
votes
4 answers

iPhone MKMapView - MKPolygon Issues

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…
Evan Klein
  • 379
  • 2
  • 6
  • 10
8
votes
2 answers

MKMapView with multiple overlays memory-issue

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,…
wkberg
  • 391
  • 2
  • 12
5
votes
2 answers

How Can I find the center coordinate in a MGLMultiPolygonFeature

I'm using iOS Mapbox SDK and I need to find the center coordinate in a polygon because I want to add a marker in the center coordinate. How can I do this in Swift? func drawPolygonFeature(shapes: [MGLShape & MGLFeature]) { let shapeSource =…
Hasti Ranjkesh
  • 643
  • 10
  • 26
5
votes
2 answers

Realm Object returning nil (Swift)

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…
Tristan Beaton
  • 1,742
  • 2
  • 14
  • 25
5
votes
1 answer

Enlarge MKCoordinateRegionForMapRect For some margin

I have some annotations presented on a map (somepoints) the map zooms in or out to fit all points - see working code below. MKPolygon *poly = [MKPolygon polygonWithPoints:somepoints count:i]; [self.mapView…
chewy
  • 8,207
  • 6
  • 42
  • 70
5
votes
3 answers

Detecting Tap on MKPolygonView in MKMapView on iOS7

Based on what I found on this SO question (Touch events on MKMapView's overlays), I have implemented a way to intercept tap gesture on MKPolygon. It was working fine in our app that was built using Xcode 4.6.3 against iOS 6. However things stopped…
dfujiwara
  • 353
  • 2
  • 11
4
votes
1 answer

Draw polygon on MapView using Swift

I have a MKMapView, and a set of coordinates I want to connect with a polygon to draw a rectangle. Below is my code that I have started with. import UIKit import MapKit class mapViewViewController: UIViewController { @IBOutlet var map:…
ez4nick
  • 9,756
  • 12
  • 37
  • 69
4
votes
2 answers

Add a label in the center of a polygon in MapKit

There are similarly named questions, like this one, but that is not what I'm looking for. Basically I'm drawing a bunch of MKPolygons on a standard map giving them a stroke, a random colour etc.. I'd like to be able to "name" them, adding a label or…
kernelpanic
  • 2,876
  • 3
  • 34
  • 58
4
votes
3 answers

MKPolygon Area Calculation Swift

I have been trying to get a calculation of MKPolygon and I have followed a few links on here and have adjusted accordingly. I cannot seem to get the right calculations of squared meters. I can provide more information if needed Here is my code func…
4
votes
2 answers

MKPolygon using Swift (Missing argument for parameter 'interiorPolygons' in call)

Fellow Devs, I'm trying to implement a polygon overlay on a mapview as follows: private func drawOverlayForObject(object: MyStruct) { if let coordinates: [CLLocationCoordinate2D] = object.geometry?.coordinates { let polygon =…
Ron
  • 1,610
  • 15
  • 23
4
votes
2 answers

Test if MKCircle intersects with MKPolygon

I'm looking for some guidance in testing if a MKPolygon intersects an MKCircle. Currently I'm using: if ([circle intersectsMapRect:[poly boundingMapRect]]) { //they do intersect } I'm finding this returns inaccurate results…
capikaw
  • 12,232
  • 2
  • 43
  • 46
3
votes
1 answer

how to automatically zoom mapView to show overlay

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…
Saurabh
  • 745
  • 1
  • 9
  • 33
1
2 3 4 5