【发布时间】:2015-12-05 07:05:43
【问题描述】:
我想展示我的景点NSArray *chSpot = [parser parseArray:responseObject];
接收 3 个对象,我想显示每个位置的经纬度
并根据我的位置找到最近的地点...我正在使用此代码:
NSArray *chSpot = [parser parseArray:responseObject];
// GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:[locLat doubleValue] // 经度:[locLong doubleValue] // 缩放:4];
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:nil];
mapView_.myLocationEnabled = YES;
mapView_.settings.myLocationButton = YES;
for (int i=0; i<chSpot.count; i++)
{
ChargingSpots *spot = [chSpot objectAtIndex:i];
NSString *locLat = spot.LocationLat;
NSString *locLong = spot.LocationLong;
// Creates a marker in the center of the map.
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake([locLat doubleValue], [locLong doubleValue]);
marker.title = @"Amman";
marker.snippet = @"Jordan";
mapView_.delegate=self;
marker.appearAnimation = kGMSMarkerAnimationPop;
marker.icon = [UIImage imageNamed:@"car"];
marker.map = mapView_;
}
//[mapView_ setSelectedMarker:marker];
self.view = mapView_;
//
//
// CLLocation *locationA = [[CLLocation alloc] initWithLatitude:[locLat doubleValue] longitude:[locLong doubleValue]];
//
// CLLocation *locationB = [[CLLocation alloc] initWithLatitude:[locLat doubleValue] longitude:[locLong doubleValue]];
//
// CLLocationDistance distance = [ locationA distanceFromLocation:locationB];
//
// NSLog (@"%f",distance);
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.distanceFilter = kCLDistanceFilterNone;
self.locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
[self.locationManager startUpdatingLocation];
【问题讨论】:
-
您当前的代码是什么?它有效吗?如果没有,你的问题是什么?
-
我已经处理了显示点的问题,但是现在我想找到我当前位置和我得到的点之间的距离,并找到最近的一个......
标签: ios objective-c