Kre*_*tin 9 google-maps ios swift flutter
设置官方Google Maps for Flutter插件的说明包括将Google API密钥添加到AppDelegate.m文件中:
在应用程序委托ios/Runner/AppDelegate.m中指定您的API密钥:
#include "AppDelegate.h"
#include "GeneratedPluginRegistrant.h"
#import "GoogleMaps/GoogleMaps.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[GMSServices provideAPIKey:@"YOUR KEY HERE"];
[GeneratedPluginRegistrant registerWithRegistry:self];
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
@end
Run Code Online (Sandbox Code Playgroud)
我的flutter项目有一个AppDelegate.swift文件而不是AppDelegate.m文件,我不知道如何添加所需的密钥,因为语法不同:
import UIKit
import Flutter
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
Run Code Online (Sandbox Code Playgroud)
谁能帮我吗?
Mo *_*ani 17
您可以按如下方式添加API密钥:
AppDelegate.swift:
import UIKit
import Flutter
import GoogleMaps // Add this line!
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
GMSServices.provideAPIKey("YOUR_API_KEY") // Add this line!
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
Run Code Online (Sandbox Code Playgroud)
Nav*_*mar 10
还有一件事,不要忘记在ios/Runner/Info.plist上添加以下行
<key>io.flutter.embedded_views_preview</key>
<true/>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1377 次 |
| 最近记录: |