У меня есть небольшая проблема, и я не знаю, почему это происходит.
Мой вид карты нормально работает в симуляторе, но на реальном устройстве я вижу только булавку на серой области и "Google"логотип.Это похоже на то, что изображения не могут быть загружены, это выглядит, когда вы увеличиваете масштаб изображения и ждете, пока представление нарисует квадрат.
Вот мой код, я был бы признателен за любую помощь
#import "Maps.h"
#import "RootViewController.h"
@implementation AddressAnnotation
@synthesize coordinate;
-(NSString *) subtitle{
return @"327 Anzac Parade, Wodonga, Victoria, Australia";
}
-(NSString *) title{
return @"Blazing Stump";
}
-(id)initWithCoordinate:(CLLocationCoordinate2D) c{
coordinate = c;
NSLog(@"%f,%f",c.latitude, c.longitude);
return self;
}
@end
@implementation Maps
-(CLLocationCoordinate2D) addressLocation{
NSString *locationString = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://maps.google.com/maps/geo?q=327%20Anzac%20Parade,%20Wodonga,%20Victoria,%20Australia&output=csv&key=ABQIAAAAZs2zFXiuKBFeLpPgSfgMjBTHxw17-t8q3X3AgrE9NufATyE8MRRmwlyLMPtOSzliJQntEtaZ7T-Rww"]
encoding:NSUTF8StringEncoding error:nil];
NSArray *listItems = [locationString componentsSeparatedByString:@","];
double latitude = -36.139226;
double longitude = 146.911454;
if ([listItems count] >=4 && [[listItems objectAtIndex:0] isEqualToString:@"200"]){
latitude = [[listItems objectAtIndex:2] doubleValue];
longitude = [[listItems objectAtIndex:3] doubleValue];
}else {
//some error
}
CLLocationCoordinate2D location;
location.latitude = latitude;
location.longitude = longitude;
return location;
}
-(MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{
MKPinAnnotationView *annView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];
annView.pinColor = MKPinAnnotationColorGreen;
annView.animatesDrop = TRUE;
annView.canShowCallout = YES;
annView.calloutOffset = CGPointMake(-5, 5);
return annView;
}
- (void)viewDidLoad {
MKCoordinateRegion region;
MKCoordinateSpan span;
span.latitudeDelta=0.2;
span.longitudeDelta=0.2;
CLLocationCoordinate2D location = [self addressLocation];
region.span=span;
region.center=location;
if(addAnnotation != nil) {
[mapView removeAnnotation:addAnnotation];
[addAnnotation release];
addAnnotation = nil;
}
addAnnotation = [[AddressAnnotation alloc] initWithCoordinate:location];
[mapView addAnnotation:addAnnotation];
[mapView setRegion:region animated:TRUE];
[mapView regionThatFits:region];
//[mapView selectAnnotation:mLodgeAnnotation animated:YES];
[super viewDidLoad];
}
- (void)dealloc {
[super dealloc];
[viewController release];
}