Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
googleplaceapi在iOS应用中的应用_Ios_Api_Google Places Api - Fatal编程技术网

googleplaceapi在iOS应用中的应用

googleplaceapi在iOS应用中的应用,ios,api,google-places-api,Ios,Api,Google Places Api,我在附近的酒吧,自动取款机,咖啡馆从用户的位置使用谷歌的地方api。它不是获取任何位置,而是给出错误描述 错误描述 此API项目无权使用此API。请确保在API控制台中激活此API:了解更多信息:https://code.google.com/apis/console 代码: - (IBAction)toolBarButtonPress:(id)sender { UIBarButtonItem *button=(UIBarButtonItem*)sender; NSStrin

我在附近的酒吧,自动取款机,咖啡馆从用户的位置使用谷歌的地方api。它不是获取任何位置,而是给出错误描述

错误描述

此API项目无权使用此API。请确保在API控制台中激活此API:了解更多信息:https://code.google.com/apis/console

代码:

  - (IBAction)toolBarButtonPress:(id)sender {
    UIBarButtonItem *button=(UIBarButtonItem*)sender;
    NSString *buttonTitle=[button.title lowercaseString];
    [self queryGooglePlaces:buttonTitle];
}
-(void)queryGooglePlaces:(NSString*)googleType  {

    NSString *url=[NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/place/search/json?location=%f,%f&radius=%@&types=%@&sensor=true&key=%@", -22.0, 137.0, [NSString stringWithFormat:@"%i", 1000], googleType, kGOOGLE_API_KEY];
    // Here kGOOGLE_API_KEY is the api key, I have created

    NSURL *googleResultsURL=[NSURL URLWithString:url];


    NSData *data=[NSData dataWithContentsOfURL:googleResultsURL];
    NSError* error;
    if(!(data==nil))
    {
    NSDictionary* json = [NSJSONSerialization
                          JSONObjectWithData:data

                          options:kNilOptions
                          error:&error];
    NSArray* places = [json objectForKey:@"error_message"];

    //Write out the data to the console.
    NSLog(@"Google Data: %@", places);
    }
    else
    {
        NSLog(@"Network error");
    }

}

有人能解释为什么它会显示此错误吗?

您是否检查并确保它已启用?在API&Auth->API->您正在使用的任何映射API下的项目中,很抱歉回复太晚。但是是的,我已经检查过了,它是启用的。我不知道它为什么会显示这个错误。很抱歉回复得太晚。但是是的,我已经检查过了,它是启用的。我不知道它为什么会显示这个错误@安迪