【问题标题】:Objective C Google maps目标 C 谷歌地图
【发布时间】:2016-02-23 13:36:05
【问题描述】:

下面是我获取位置纬度和经度的代码,但无论何时执行它都会返回:

您已超出此 API 的每日请求配额。我们建议在 Google Developers Console 中注册密钥。

我有我的 API 密钥,但我不知道把它放在哪里。

GoogleMapsViewController *obj=[self.storyboard instantiateViewControllerWithIdentifier:@"googlemap"];
NSString *givensource=self.sourcetxt.text;
NSString *givendest=self.destinationtxt.text;
NSString *sendtourl=[NSString stringWithFormat:@"https://maps.google.com/maps/api/geocode/json?sensor=false&address=%@",givensource];

NSURL *url = [NSURL URLWithString:sendtourl];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[NSURLConnection
    sendAsynchronousRequest:request
    queue:[NSOperationQueue mainQueue]
    completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
    if (data.length > 0 && connectionError == nil) {
        NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:NULL];
        NSLog(@"ABC");
    }
}];

【问题讨论】:

标签: ios objective-c iphone google-maps-sdk-ios


【解决方案1】:

为此,您需要注册您的应用程序并获取 API 密钥。您需要通过在每个请求中附加 URL 来使用此 API 密钥:

NSString *sendtourl = [NSString stringWithFormat:@"https://maps.google.com/maps/api/geocode/json?sensor=false&address=%@?key=your key", givensource]; 

【讨论】:

  • 如何追加? @Rohit KP
  • 我已经有密钥并注册了我的应用,但不知道请求的正确语法
  • 用数字键替换文本键
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-11-28
  • 2015-09-12
  • 2015-12-20
  • 1970-01-01
相关资源
最近更新 更多