googleMap sdk for iOS的一些使用 介绍问题

本文介绍了如何在iOS应用中集成并使用Google Maps SDK,包括下载SDK、设置API Key、添加依赖库、配置项目设置以及解决可能出现的地图显示问题。在遇到地图不显示的情况下,建议检查API Key的有效性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

https://developers.google.com/maps/documentation/ios/start

首先下载Google Map的sdk for iOS 

申请 APIKey

  1. Launch Xcode and either open an existing project, or create a new project.
    • If you're new to iOS, create a Single View Application, and disable Use Storyboards but ensure that Use Automatic Reference Counting is on.
  2. Drag the GoogleMaps.framework bundle to the Frameworks group of your project. When prompted, select Copy items into destination group's folder.
  3. Right-click GoogleMaps.framework in your project, and select Show In Finder.
  4. Drag the GoogleMaps.bundle from the Resources folder to your project. We suggest putting it in the Frameworks group. When prompted, ensure Copy items into destination group's folder is not selected.
  5. Select your project from the Project Navigator, and choose your application's target.
  6. Open the Build Phases tab, and within Link Binary with Libraries, add the following frameworks:
    • AVFoundation.framework
    • CoreData.framework
    • CoreLocation.framework
    • CoreText.framework
    • GLKit.framework
    • ImageIO.framework
    • libc++.dylib
    • libicucore.dylib
    • libz.dylib
    • OpenGLES.framework
    • QuartzCore.framework
    • SystemConfiguration.framework
  7. Choose your project, rather than a specific target, and open the Build Settings tab.
    • Replace the default value of Architectures with armv7.
    • In the Other Linker Flags section, add -ObjC. If these settings are not visible, change the filter in the Build Settings bar from Basic to All.
  8. Finally, add your API key to your AppDelegate.
    • #import <GoogleMaps/GoogleMaps.h>
    • Add the following to your application:didFinishLaunchingWithOptions: method, replacing YOUR_API_KEY with your API key.
      [GMSServices provideAPIKey:@"YOUR_API_KEY"];
      添加地图到你的View
      #import "YourViewController.h"
      #import <GoogleMaps/GoogleMaps.h>
      
      @implementation YourViewController {
        GMSMapView *mapView_;
      }
      
      // You don't need to modify the default initWithNibName:bundle: method.
      
      - (void)loadView {
        GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.8683
                                                                longitude:151.2086
                                                                     zoom:6];
        mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
        mapView_.myLocationEnabled = YES;
        self.view = mapView_;
      
        GMSMarker *marker = [[GMSMarker alloc] init];
        marker.position = CLLocationCoordinate2DMake(-33.8683, 151.2086);
        marker.title = @"Sydney";
        marker.snippet = @"Australia";
        marker.map = mapView_;
      }

      如果运行之后只显示了添加的图标 ,而没有显示地图 是

      APIkey的问题 , ,一般情况下,重新获取下apikey 可以了 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值