gpt4 book ai didi

ios - 用于 Flutter iOS Swift 设置的谷歌地图

转载 作者:IT老高 更新时间:2023-10-28 12:34:05 24 4
gpt4 key购买 nike

设置官方 Google Maps for Flutter 插件的说明包括将 Google API key 添加到 AppDelegate.m 文件中:

在应用程序委托(delegate) ios/Runner/AppDelegate.m 中指定您的 API key :

#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

我的 flutter 项目有一个 AppDelegate.swift 文件而不是一个 AppDelegate.m 文件,我不确定如何添加所需的 key ,因为语法不同:

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)
}
}

谁能帮帮我?

最佳答案

您可以按如下方式添加您的 API key :

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)
}
}

关于ios - 用于 Flutter iOS Swift 设置的谷歌地图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53789449/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com