0
这是我的代码:Objective-C的谷歌静态地图返回nil
#define GOOGLE_STATIC_MAP_IMAGE @"https://maps.googleapis.com/maps/api/staticmap?center=%@&zoom=15&size=320x150&maptype=roadmap&markers=color:green|label:H|%@"
-(UIImage*)GetGoogleStaticMap
{
NSString* coordinates = [NSString stringWithFormat:@"%f,%f", latitude, longitude];
NSString *stringURL = [NSString stringWithFormat:GOOGLE_STATIC_MAP_IMAGE, coordinates, coordinates]; //coordinates x2 = for the center & the marker
NSURL *url = [NSURL URLWithString:stringURL];
NSData *imageData = [[NSData alloc] initWithContentsOfURL:url];
UIImage *image = [UIImage imageWithData:imageData];
return image;
}
,如果我贴stringURL到浏览器中,我得到了想要的结果,但为imageData返回nil - 想法?