【发布时间】:2015-09-14 16:03:09
【问题描述】:
我正在使用一种方法来获取我的位置:
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
CLLocation *currentLocation = newLocation;
NSLog(@"%@", currentLocation);}
//new method to find the distance
-(void) zoomToNearestSpot: (NSArray *) spot location: (CLLocation *)myLocation
{
myLocation = currentLocation;
spot = chSpot;
for (int i=0; i< spot.count; i++)
{
ChargingSpots *mySpot = [spot objectAtIndex:i];
CLLocation *thePoint = [[CLLocation alloc]initWithLatitude:[mySpot.LocationLat doubleValue] longitude:[mySpot.LocationLong doubleValue]];
CLLocationDistance dist = [myLocation distanceFromLocation:thePoint];
NSLog(@"%f", dist);
you get here **distance** in meter so in assumption **20 miles = 32187 meter**
设置条件,例如
if(distance <= 32187)
{
// under 20 miles you can add the zoom level
}
else
{
// out of 20 miles
}
}
}
首先,我需要根据它们的数量缩小地图上的所有地点,然后找到最近的地点并将相机放大。
【问题讨论】:
标签: ios objective-c