Possible Duplicate:
GPS coordinates in degrees to calculate distances
How to Calculate distance between two place using latitude-longitude in gmap for iPhone? Calculate distance between two place using latitude-longitude in gmap for iPhone
from math import cos, asin, sqrt, pi def distance(lat1, lon1, lat2, lon2): p = pi/180 a = 0.5 - cos((lat2-lat1)*p)/2 + cos(lat1*p) * cos(lat2*p) * (1-cos((lon2-lon1)*p))/2 return 12742 * asin(sqrt(a)) #2*R*asin...
Get GPS Coordinates in Maps on iPhone and iPadTap the current location button on the top right. When the blue circle for your spot appears on the map, tap it. Swipe up from the bottom to view full details for your location and you'll see the Latitude and Longitude.
You have to use Core Location Framework. So don't forget to Add & import Core Location Framework.
#import <CoreLocation/CoreLocation.h> CLLocation *locA = [[CLLocation alloc] initWithLatitude:lat1 longitude:long1]; CLLocation *locB = [[CLLocation alloc] initWithLatitude:lat2 longitude:long2]; CLLocationDistance distance = [locA distanceFromLocation:locB]; //distance in Meters //1 meter == 100 centimeter //1 meter == 3.280 feet //1 square meter == 10.76 square feet [locA release]; [locB release];
import CoreLocation let locA = CLLocation(latitude: lat1, longitude: long1) let locB = CLLocation(latitude: lat2, longitude: long2) let distance = locA.distance(from: locB)
if you have the location parameter, create 2 CLLocations and use [location1 distanceFromLocation:location2]
method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With