I have a CLLocation defined, and I'd like to move that point x meters to the east and y meters to the south. How may I achieve that?
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- how do you prevent page scroll in textarea on mobi
- Custom UITableview cell accessibility not working
相关文章
- Could I create “Call” button in HTML 5 IPhone appl
- Xcode: Is there a way to change line spacing (UI L
- Unable to process app at this time due to a genera
- How do you detect key up / key down events from a
- “Storyboard.storyboard” could not be opened
- Open iOS 11 Files app via URL Scheme or some other
- Taking np.average while ignoring NaN's?
- Can keyboard of type UIKeyboardTypeNamePhonePad be
Swift implementation using
Measurement
struct to do the conversions between degrees and radians.There is a C function that is close to what you are asking but it takes a bearing and distance. It's in my UtilitiesGeo class on github. You would pass the latitude and longitude from your CLLocation to it and then create a new CLLocation from the resulting lat2 and lon2 that it returns:
If you can't use that, take a look at the algorithms that it was derived from here and here and perhaps you can modify it or those sites might have something closer to your needs.
Improved swift solution to Peters answer. Only correction is the bearing should be radian while calculation has been made.
Great post, here's the Obj-C wrapper for those who love copy/paste:
A simpler solution is to use MKMapPoints.
Convert your original coordinates, and any offset distances you need to MKMapPoints using this:
Then make a new MKMapPoint by simply adding your offset distances to your original coordinates:
Finally, convert the new coordinates from a MKMapPoint back to CLLocationCoordinate2D:
No complex conversion calculations needed.
A conversion to Swift, taken from this answer: