无法在ios中使用Google地图sdk

时间:2015-02-06 09:33:31

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

我正在使用一个简单的iOS应用程序,我正在整合Google地图。但没有得到任何结果。 我已经使用了这个步骤

第1步:我已下载Google Maps Mobile SDK 来自此链接sdk ios

第2步:在Google API控制台中创建API项目。

第3步:在API项目中选择“服务”窗格,然后启用适用于iOS的Google Maps SDK。这会显示Google地图服务条款。

enter image description here 获取活动状态Google API控制台。 enter image description here 步骤4:i在控制台中选择API Access窗格,然后单击Create new iOS key。

enter image description here

然后我在AppDelegate.m中添加了API Key,就像这样

#import "AppDelegate.h"
#import <GoogleMapsM4B/GoogleMaps.h>
@interface AppDelegate ()

@end

@implementation AppDelegate


    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        // Override point for customization after application launch.

        NSLog(@"Current identifier: %@", [[NSBundle mainBundle] bundleIdentifier]);
        [GMSServices provideAPIKey:@"AIzaSTyurcyzpvoRv3gCPJRiw7Dc6dXkTMfOI2w"];
        return YES;
    }

但我没有得到结果。在日志中我收到此错误

Gmap[3836:883464] Current identifier: com.example.Gmap
2015-02-06 14:39:41.790 Gmap[3836:883464] Google Maps SDK for iOS (M4B) version: 1.9.13516.0
2015-02-06 14:39:42.014 Gmap[3836:883464] ClientParametersRequest failed, 3 attempts remaining (0 vs 6). Error Domain=com.google.HTTPStatus Code=400 "The operation couldn’t be completed. (com.google.HTTPStatus error 400.)" UserInfo=0x7f922a67fcd0 {data=<CFData 0x7f922d4615a0 [0x1049039a0]>{length = 145, capacity = 256, bytes = 0x3c48544d4c3e0a3c484541443e0a3c54 ... 3c2f48544d4c3e0a}}
2015-02-06 14:39:42.213 Gmap[3836:883464] ClientParametersRequest failed, 2 attempts remaining (0 vs 6). Error Domain=com.google.HTTPStatus Code=400 "The operation couldn’t be completed. (com.google.HTTPStatus error 400.)" UserInfo=0x7f922a4d7540 {data=<CFData 0x7f922d48dd90 [0x1049039a0]>{length = 145, capacity = 256, bytes = 0x3c48544d4c3e0a3c484541443e0a3c54 ... 3c2f48544d4c3e0a}}
2015-02-06 14:39:46.594 Gmap[3836:883464] ClientParametersRequest failed, 1 attempts remaining (0 vs 6). Error Domain=com.google.HTTPStatus Code=400 "The operation couldn’t be completed. (com.google.HTTPStatus error 400.)" UserInfo=0x7f922a6a4a50 {data=<CFData 0x7f922a798c00 [0x1049039a0]>{length = 145, capacity = 256, bytes = 0x3c48544d4c3e0a3c484541443e0a3c54 ... 3c2f48544d4c3e0a}}
2015-02-06 14:39:55.528 Gmap[3836:883464] ClientParametersRequest failed, 0 attempts remaining (0 vs 6). Error Domain=com.google.HTTPStatus Code=400 "The operation couldn’t be completed. (com.google.HTTPStatus error 400.)" UserInfo=0x7f922d49fed0 {data=<CFData 0x7f922a6406e0 [0x1049039a0]>{length = 145, capacity = 256, bytes = 0x3c48544d4c3e0a3c484541443e0a3c54 ... 3c2f48544d4c3e0a}}
2015-02-06 14:39:55.529 Gmap[3836:883464] Google Maps SDK for iOS (M4B) cannot connect or validate APIKey: Error Domain=com.google.HTTPStatus Code=400 "The operation couldn’t be completed. (com.google.HTTPStatus error 400.)" UserInfo=0x7f922d49fed0 {data=<CFData 0x7f922a6406e0 [0x1049039a0]>{length = 145, capacity = 256, bytes = 0x3c48544d4c3e0a3c484541443e0a3c54 ... 3c2f48544d4c3e0a}}
2015-02-06 14:39:55.529 Gmap[3836:883464] Your key may be invalid for your bundle ID: com.example.Gmap

有人可以帮助在这里找到错误。这里缺少什么。无法弄清楚为什么会出现这个错误。在运行应用程序后,这个模拟器屏幕。 enter image description here

2 个答案:

答案 0 :(得分:3)

正如我们在评论中已经说过的那样,您使用了错误的库 - Google Maps SDK for Work iOS(商家),但您正在尝试生成Google Maps SDK for iOS的密钥(您正在使用:{{1}而不是#import <GoogleMapsM4B/GoogleMaps.h>

答案 1 :(得分:0)

对于GoogleMaps框架,您需要安装可可豆荚,然后在终端pod try GoogleMaps中键入以下内容 这将安装pod并下载googlemaps框架。它会 完成后打开一个示例项目。您可以在项目中找到框架和映射包。使用此框架我的问题已得到解决。下面是我机器上框架的完整路径: /私有的/ var /文件夹/ 9B / w5tw8dwx3vsddqw1g0r1rksr0000gn / T /的CocoaPods /尝试

希望这会有所帮助:)