Google Map API

Judy·2021년 6월 16일
0

지도 API

장소의 위치를 얻어오고 표시하기 위해 지도 API가 필요했다.
안드로이드 앱 제작 시에 이용하기도 했고 공식문서에 설명이 자세해서 Google Map을 이용하기로 결정!

Google API 사용

  1. API 생성

  1. pod install

pod 'Google Maps'
pod 'Google Places'

  1. API key와 연결
  1. Google Map 예시코드
        self.view.backgroundColor = #colorLiteral(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0)
          
        let camera = GMSCameraPosition.camera(withLatitude: -33.86, longitude: 151.20, zoom: 6.0)
        let mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
            
        view = mapView
            
        let marker = GMSMarker()
        marker.position = CLLocationCoordinate2D(latitude: -33.86, longitude: 151.20)
         marker.title = "Sydney"
         marker.snippet = "Australia"
         marker.map = mapView

까지 했는데 갑자기 빌드 에러 발생....

building for iOS Simulator, but linking in object file built for iOS, file '/Users/kimjuyoung/Documents/Xcode/Project/WeThereProject/Pods/GoogleMaps/Maps/Frameworks/GoogleMaps.framework/GoogleMaps' for architecture arm64

여러 사이트를 참고해서 시도해봤지만 Arm-based Macs에선 Map SDK가 실행되지 않는다는 결론을 얻고 결국 Physical Device로 테스트하기로 했다 😂


디바이스에 에러 없이 화면을 띄우는데 성공했지만 지도가 표시되지 않았다...

  • info.plist에 위치 권한 설정

  • API 사용 설정

위 두 설정을 추가하니 드디어 지도가 뜬다!!!!

# 소감 #

한참 모자란 나.. 에러가 계속 돼서 힘들었다.

다음 목표

현재 위치 표시하기, 장소 검색해서 주소 받아오기




참고 : Maps SDK for iOS

profile
iOS Developer

0개의 댓글