【发布时间】:2023-03-27 12:00:01
【问题描述】:
我正在尝试使用 Google 静态地图 API,但它没有返回任何内容。 API 密钥是正确的,我已成功使用 Google Places API。 IDK我做错了什么。我试过只使用必需的参数,什么也没有。我也尝试过使用 API Docs 中的示例 URL,但也没有。
NSString *url = [NSString stringWithFormat:@"http://maps.googleapis.com/maps/api/staticmap?zoom=18&size=320x120&visual_refresh=true&markers=size:mid|color:0x00AB8B|%f,%f&key=AIzaSyDbg7wrSq-USEJWUqf5TOPepbtGRwbYtg8", [LocationController sharedSingleton].locationManager.location.coordinate.latitude, [LocationController sharedSingleton].locationManager.location.coordinate.longitude];
NSURL *googleURL = [NSURL URLWithString:[url stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]];
dispatch_async(kBgQueue, ^{
NSData* data = [NSData dataWithContentsOfURL: googleURL];
NSLog(@"data size: %lu", (unsigned long)[data length]);
if (data.length != 0){
[mapViewArray addObject:data];
}
});
【问题讨论】:
-
此链接将对您有所帮助。 stackoverflow.com/questions/34851795/…
标签: ios objective-c google-maps google-static-maps