Я работаю с MKMapView, аннотациями, оверлеями и т. Д., Но у меня болит проблема с приложением MKMapPointForCoordinate(), возвращая недопустимую координату.MKMapPointForCoordinate возвращает недействительные координаты
Код:
MKMapPoint* pointArr;
for (Category* route in validRoutes){
NSString* routeID = [route routeid];
NSArray* pointData = [routes objectForKey:routeID];
pointArr = malloc(sizeof(MKMapPoint) * [pointData count]);
int i = 0;
for (NSDictionary* routeData in pointData) {
NSString* latitude = [routeData objectForKey:@"latitude"];
NSString* longitude = [routeData objectForKey:@"longitude"];
NSLog(@"L: %@ L: %@",latitude, longitude);
CLLocationCoordinate2D coord = CLLocationCoordinate2DMake([[f numberFromString:latitude] doubleValue], [[f numberFromString:longitude] doubleValue]);
NSLog(@"Coord: %f %f",coord.latitude,coord.longitude);
MKMapPoint point = MKMapPointForCoordinate(coord);
NSLog(@"Point: %f %f",point.x,point.y);
pointArr[i] = point;
i++;
}
MKPolyline *polyline = [MKPolyline polylineWithPoints:pointArr count: i];
polyline.title = [route name];
[routeOverlays setObject:polyline forKey: [route routeid]];
[map addOverlay:polyline];
free(pointArr);
}
Выход Пример:
Л: 41,380840 Л: -83,641319
Coord: 41,380840 -83,641319
Точка: 71850240,204982 +100266073,824832
Я дон Не понимаю, почему преобразование в MKMapPoint уничтожая значения моего CLLocationCoordinate2D. Оверлей не отображается на карте, потому что значения недопустимы ...
EDIT: Я получил смысл работать с использованием MKMapPointMake, НО, мое оверлей все еще не отображается. Это MAPview: viewForOverlay: Код:
-(MKOverlayView*)mapView:(MKMapView *)mapView viewForOverlay:(id<MKOverlay>)overlay {
MKOverlayView *overlayView = nil;
//Checks if the overlay is of type MKPolyline
if([overlay isKindOfClass:[MKPolyline class]]){
MKPolylineView *routeLineView = [[MKPolylineView alloc] initWithPolyline:overlay];
routeLineView.strokeColor = [UIColor orangeColor];
routeLineView.lineWidth = 10;
return overlayView;
}
return nil;
}
Метод вызывается (используется точкой останова для подтверждения), и у меня есть аннотации работают (Таким образом, делегат должен правильно быть установлено, я предполагаю)
Double edit:: facepalm: Я возвращал ноль каждый раз в коде делегата. Это то, что я получаю для копирования и вставки предыдущей версии кода; P
Мне удалось заставить MKMapPoint работать с помощью MKMapPointMake (x, y) с координатами.latitude и Coord.longitude, но он по-прежнему не отображается на карте. =/ –