Mar*_*rco 24 iphone cocoa-touch cllocationmanager
我在viewDidLoad中有以下循环:
for(int i=1; i<[eventsArray count]; i++) {
NSArray *componentsArray = [[eventsArray objectAtIndex:i] componentsSeparatedByString:@","];
if([componentsArray count] >=6) {
Koordinate *coord = [[Koordinate alloc] init];
coord.latitude = [[componentsArray objectAtIndex:0] floatValue];
coord.longtitude = [[componentsArray objectAtIndex:1] floatValue];
coord.magnitude = [[componentsArray objectAtIndex:2] floatValue];
coord.depth = [[componentsArray objectAtIndex:3] floatValue];
coord.title = [componentsArray objectAtIndex:4];
coord.strasse = [componentsArray objectAtIndex:5];
coord.herkunft = [componentsArray objectAtIndex:6];
coord.telefon = [componentsArray objectAtIndex:7];
coord.internet = [componentsArray objectAtIndex:8];
[eventPoints addObject:coord];
}
Run Code Online (Sandbox Code Playgroud)
coord是CLLocationCoordinate2D
但是我如何在下面的方法中使用coord,因为我需要这个以获得两个坐标之间的距离:
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation{
}
Run Code Online (Sandbox Code Playgroud)
请帮帮我,我被困了!
谢谢大家事先帮忙
Ale*_*gel 40
CLLocation有一个名为的init方法-(id)initWithLatitude:(CLLocationDegrees)latitude longitude:(CLLocationDegrees)longitude.然后- (CLLocationDistance)getDistanceFrom:(const CLLocation *)location用来获取两个CLLocation对象之间的距离.
Can*_*rek 11
简单
CLLocation *location = [[CLLocation alloc] initWithLatitude:lat longitude:lon];
Run Code Online (Sandbox Code Playgroud)
对于斯威夫特人群,
我有一个名为"fetchCafesArroundLocation"的方法,在地图移动后刷新.这就是我如何处理从CLLocationCoordiate2d获取Lat和Lon到CLLocation然后将CLLocation变量传递给处理方法的方法.
func mapView(mapView: MKMapView!, regionDidChangeAnimated animated: Bool){
var centre = mapView.centerCoordinate as CLLocationCoordinate2D
var getLat: CLLocationDegrees = centre.latitude
var getLon: CLLocationDegrees = centre.longitude
var getMovedMapCenter: CLLocation = CLLocation(latitude: getLat, longitude: getLon)
self.lastLocation = getMovedMapCenter
self.fetchCafesAroundLocation(getMovedMapCenter)
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
37179 次 |
| 最近记录: |