开发者

Distance between 2 or more drop pins

开发者 https://www.devze.com 2023-02-16 10:40 出处:网络
I was doing a small assignment,in which i was finding the distance between Green drop pin and red drop pins.The green pin shows 开发者_Go百科the user location and red pins shows his friend\'s location

I was doing a small assignment,in which i was finding the distance between Green drop pin and red drop pins.The green pin shows 开发者_Go百科the user location and red pins shows his friend's location.But i don't have any idea how can do it?So please if somebody help me regarding my problem,I shall be thankful.


You can try using distanceFromLocation:.

Pls go through the Reference

Update:

// Assumption: lat1, lon1 and lat2, lon2 are double values containing the coordinates

CLLocation *firstLocation = [[[CLLocation alloc] initWithLatitude:lat1 longitude:lon1] autorelease];
CLLocation *secondLocation = [[[CLLocation alloc] initWithLatitude:lat2 longitude:lon2] autorelease];
CLLocationDistance distance = [secondLocation distanceFromLocation:firstLocation];
0

精彩评论

暂无评论...
验证码 换一张
取 消