i'm trying detect if map annotation inside mkcircle. have tirelessly traversed internet little luck of finding solid tutorial of swift 2.0. tutorial or stack overflow questions answered deprecated code or objective-c. unfortunately, pretty new swift, translating answers bit difficult.
what have far:
so far, have declared circle mkcircle looks like,
let location = cllocationcoordinate2d(latitude: 36.9900, longitude: -122.0605) let circle = mkcircle(centercoordinate: location, radius: 100)
and want use cgpathcontainspoint detect if annotation inside circle. definition cgpathcontainspoint looks like,
cgpathcontainspoint(_ path: cgpath?, _ m: unsafepointer<cgaffinetransform>, _ point: cgpoint, _ eofill: bool) -> bool
where,
path - path check point against
m - affine transform (not sure purpose of questions have set param nil)
point - point in question
eofill - use even-odd fill (true or false, again not sure questions have set false)
my question: how convert or translate mkcircle behaves cgpath in order pass cgpathcontainspoint , convert cllocationcoordinate2d cgpoint?
why use complicated path evaluation find out if point inside circle? variation on describe might make sense testing points against arbitrarily complex regions, you're talking circle. definition of circle set of points distance (radius) chosen point (the center). so:
- create
cllocation
objects both circle center , point tested. - use
distancefromlocation:
method find distance between them. - if distance less 100 meters (the radius of circle), target point inside circle. otherwise it's outside.
Comments
Post a Comment