質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Xcode

Xcodeはソフトウェア開発のための、Appleの統合開発環境です。Mac OSXに付随するかたちで配布されています。

Swift

Swiftは、アップルのiOSおよびOS Xのためのプログラミング言語で、Objective-CやObjective-C++と共存することが意図されています

Google マップ

Google Mapは、Google社がオンラインで提供している地図・ローカル検索サービスです。GIS(Geographic Information System:地理情報システム)の中の「WebGIS」に該当します。地図・航空写真・地形の表示方式があり、それぞれユーザーが縮尺を調整して表示させることができます。地域の情報サービスを検索する機能やルート検索の機能も搭載されています。

Q&A

解決済

1回答

1708閲覧

XcodeでGoogleMapsSDKが表示されない

akidon0000

総合スコア8

Xcode

Xcodeはソフトウェア開発のための、Appleの統合開発環境です。Mac OSXに付随するかたちで配布されています。

Swift

Swiftは、アップルのiOSおよびOS Xのためのプログラミング言語で、Objective-CやObjective-C++と共存することが意図されています

Google マップ

Google Mapは、Google社がオンラインで提供している地図・ローカル検索サービスです。GIS(Geographic Information System:地理情報システム)の中の「WebGIS」に該当します。地図・航空写真・地形の表示方式があり、それぞれユーザーが縮尺を調整して表示させることができます。地域の情報サービスを検索する機能やルート検索の機能も搭載されています。

0グッド

0クリップ

投稿2020/03/04 07:22

###問題点
イメージ説明
シュミレーターを起動するとこの表示から地形が読み込まれません。
ピンはシドニーを指しています。
拡大、縮小はできます。
地形を読み込まれるようにしたいです。
よろしくお願いします。

###コード

AppDelegate

1//AppDelegate.swift 2import UIKit 3import GoogleMaps 4import GooglePlaces 5 6@UIApplicationMain 7class AppDelegate: UIResponder, UIApplicationDelegate { 8 9 var window: UIWindow? 10 11 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 12 GMSServices.provideAPIKey("**key**") 13 GMSPlacesClient.provideAPIKey("**key**") 14 return true 15 } 16 17 // MARK: UISceneSession Lifecycle 18 19 @available(iOS 13.0, *) 20 func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 21 // Called when a new scene session is being created. 22 // Use this method to select a configuration to create the new scene with. 23 return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 24 } 25 26 @available(iOS 13.0, *) 27 func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) { 28 // Called when the user discards a scene session. 29 // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 30 // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 31 } 32}

SceneDelegate

1//SceneDelegate.swift 2 3 4import UIKit 5 6class SceneDelegate: UIResponder, UIWindowSceneDelegate { 7 8 var window: UIWindow? 9 10 11 @available(iOS 13.0, *) 12 func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 13 // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 14 // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 15 // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 16 guard let _ = (scene as? UIWindowScene) else { return } 17 } 18 19 @available(iOS 13.0, *) 20 func sceneDidDisconnect(_ scene: UIScene) { 21 // Called as the scene is being released by the system. 22 // This occurs shortly after the scene enters the background, or when its session is discarded. 23 // Release any resources associated with this scene that can be re-created the next time the scene connects. 24 // The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead). 25 } 26 27 @available(iOS 13.0, *) 28 func sceneDidBecomeActive(_ scene: UIScene) { 29 // Called when the scene has moved from an inactive state to an active state. 30 // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 31 } 32 33 @available(iOS 13.0, *) 34 func sceneWillResignActive(_ scene: UIScene) { 35 // Called when the scene will move from an active state to an inactive state. 36 // This may occur due to temporary interruptions (ex. an incoming phone call). 37 } 38 39 @available(iOS 13.0, *) 40 func sceneWillEnterForeground(_ scene: UIScene) { 41 // Called as the scene transitions from the background to the foreground. 42 // Use this method to undo the changes made on entering the background. 43 } 44 45 @available(iOS 13.0, *) 46 func sceneDidEnterBackground(_ scene: UIScene) { 47 // Called as the scene transitions from the foreground to the background. 48 // Use this method to save data, release shared resources, and store enough scene-specific state information 49 // to restore the scene back to its current state. 50 } 51}

ViewController

1//ViewController.swift 2import UIKit 3import GoogleMaps 4import GooglePlaces 5 6class ViewController: UIViewController { 7 8 override func viewDidLoad() { 9 super.viewDidLoad() 10 11 let camera = GMSCameraPosition.camera(withLatitude: 35.681236, longitude: 139.767125, zoom: 2.0) 12 13 //CGRect.zero,view.frame 14 let mapView = GMSMapView.map(withFrame: view.bounds, camera: camera) 15 self.view = mapView 16 let marker = GMSMarker() 17 marker.position = CLLocationCoordinate2D(latitude: -33.86, longitude: 151.20) 18 marker.title = "Sydney" 19 marker.snippet = "Australia" 20 marker.map = mapView 21 //self.view.backgroundColor = .red 22 } 23}

Podfile

1//podfile 2target 'Gmap_test' do 3 # Comment the next line if you don't want to use dynamic frameworks 4 use_frameworks! 5 6 #Pods for Gmap_test 7 pod 'GoogleMaps' 8 pod 'GooglePlaces' 9 10end

###エラー
エラーは表示されていないです。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

takabosoft

2020/03/04 07:42

GMSServices.provideAPIKey("**key**") GMSPlacesClient.provideAPIKey("**key**") 念の為確認ですが、この2つの処理はブレークポイントを張ってデバッグ実行したときに、ブレークしますよね?(コード通ってますよね)
akidon0000

2020/03/04 08:13

はい。試しましたが、ちゃんと動きました。 **key**もgoogleの認証APIキーから持ってきました。
dsuzuki

2020/03/04 10:07

逆に、Mapを表示したいアプリのBundleIDをGoogle側に設定していますか?
akidon0000

2020/03/04 12:00

BundleIDは設定しています!
guest

回答1

0

自己解決

解決しました。ありがとうございます。

###解決方法
Googleでキーを取得する認証情報上のライブラリを選択し、Maps SDK for ios のAPIを有効にする。

###参考動画
https://www.youtube.com/watch?v=oSeyt1IkWis

投稿2020/03/05 05:04

akidon0000

総合スコア8

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問