无法指定经纬度方向
Cannot specify direction of longitude and latitude
目前我有两个文本字段,用于保存我的经度和纬度坐标值。虽然出于某种原因,如果我在坐标的末尾输入 N、S、E、W 来指定方向,但它似乎被忽略了,只取数值,实习生把我带到了错误的位置。
这是我到目前为止所做的。
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
mapview.showsUserLocation = YES;
MKCoordinateRegion region = { {0.0, 0.0}, {0.0,0.0}};
region.center.latitude = [self.myTextField.text floatValue];
region.center.longitude = [self.myTextField1.text floatValue];
region.span.longitudeDelta = 0.01f;
region.span.latitudeDelta = 0.01f;
[mapview setRegion:region animated:YES];
MapPin *ann = [[MapPin alloc] init];
ann.title = @"Test";
ann.subtitle = @"test";
ann.coordinate = region.center;
[mapview addAnnotation:ann];
}
您尝试设置的值是 CLLocationDegrees. To specify latitudes south of the equator or longitudes west of Greenwich, use negative numbers. The floatVlaue
property您使用的只是丢弃您在末尾键入的字母,因为它们不被识别为浮点值的一部分.
目前我有两个文本字段,用于保存我的经度和纬度坐标值。虽然出于某种原因,如果我在坐标的末尾输入 N、S、E、W 来指定方向,但它似乎被忽略了,只取数值,实习生把我带到了错误的位置。
这是我到目前为止所做的。
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
mapview.showsUserLocation = YES;
MKCoordinateRegion region = { {0.0, 0.0}, {0.0,0.0}};
region.center.latitude = [self.myTextField.text floatValue];
region.center.longitude = [self.myTextField1.text floatValue];
region.span.longitudeDelta = 0.01f;
region.span.latitudeDelta = 0.01f;
[mapview setRegion:region animated:YES];
MapPin *ann = [[MapPin alloc] init];
ann.title = @"Test";
ann.subtitle = @"test";
ann.coordinate = region.center;
[mapview addAnnotation:ann];
}
您尝试设置的值是 CLLocationDegrees. To specify latitudes south of the equator or longitudes west of Greenwich, use negative numbers. The floatVlaue
property您使用的只是丢弃您在末尾键入的字母,因为它们不被识别为浮点值的一部分.