SlideShare a Scribd company logo
1 of 33
iOS APP Development
   Map&Location
     地圖與定位

             鐘祥仁 Ryan
             ryan@iii.org.tw

   Map&GPS         1   http://MobileDev.TW
大綱
• 定位
 • 拿到經緯度
 • 將定位轉換成地址
• 地圖應用
 • 將定位位置秀在地圖上
 • 地圖形態:一般、衛星、混合
 • 加入自定圖標
    • 區分各別自定圖標
    • 客製化圖標影像
  • 導航 (iOS6 Apple Map)
         Map&GPS     2    http://MobileDev.TW
1.定位
•  拿到自己的經緯度




       Map&GPS    3   http://MobileDev.TW
定位
1.  點選target --> Build Phases --> Link Binary With
    Libraries,加入CoreLocation.framework
2.  在需要定位的.h檔中import,並且遵
    循CLLocationManagerDelegate,並加入一
    個iVar,資料形態為CLLocationManager




           Map&GPS      4   http://MobileDev.TW
定位
3.  在viewDidLoad中加入




         Map&GPS      5   http://MobileDev.TW
定位
 4.  實作didUpdateToLocation方法,取得目前經緯度




4.  實作didUpdateLocations方法,取得目前經緯度(iOS6)




          Map&GPS   6   http://MobileDev.TW
2.將定位轉換成地址




Map&GPS   7   http://MobileDev.TW
將定位轉換成地址
1.  在畫面上新增兩個Label
2.  定位完成後,使用CLGeocoder
    的reverseGeocodeLocation來進行轉換




         Map&GPS   8   http://MobileDev.TW
3.將定位位置秀在地圖上




Map&GPS   9   http://MobileDev.TW
將定位位置秀在地圖上
1.  加入MapKit.framework
2.  import Mapkit、加入delegate、拉MapView (
     勾選Shows User Location、Allows Zooming
     、Allows Scrolling)




          Map&GPS   10   http://MobileDev.TW
將定位位置秀在地圖上
3.  在取得經緯度時,設定mapView的中心位置與縮
    放尺寸




       Map&GPS   11   http://MobileDev.TW
3.Lab
•  MapView有三種呈現方式,透過setMapType方法
   可以進行設定:
 •  MKMapTypeStandard
 •  MKMapTypeSatellite
 •  MKMapTypeHybrid
•  請結合Segmented Control,讓使用者可以切換地
   圖呈現方式




          Map&GPS        12   http://MobileDev.TW
Lab




Map&GPS   13   http://MobileDev.TW
Lab
1.  拉進Segmented Control,設定成三顆




        Map&GPS   14   http://MobileDev.TW
Lab
2.  建立程式關聯性,action
3.  修改sender形態為UISegmentedControl*




         Map&GPS   15   http://MobileDev.TW
Lab
4.  當SegmentedControl值改變時,就對應變更地圖
    呈現的方式




        Map&GPS   16   http://MobileDev.TW
4.加入自定圖標




Map&GPS   17   http://MobileDev.TW
加入自定圖標
1.  建立新檔案,繼承NSObject,命名
    為MyAnnotation,遵循<MKAnnotation>




         Map&GPS   18   http://MobileDev.TW
加入自定圖標
2.  MyAnnotation.m




          Map&GPS    19   http://MobileDev.TW
加入自定圖標
3.  製作一個方法來加入多個自定圖標




      Map&GPS   20   http://MobileDev.TW
加入自定圖標
4.  在地圖跳至目前位置之後,呼叫加入自定圖標的方法




      Map&GPS   21   http://MobileDev.TW
5.區分各別自定圖標




Map&GPS   22   http://MobileDev.TW
區分各別自定圖標
1.  利用在viewForAnnotation方法中的annotation
    的標題或子標題來區分




         Map&GPS   23   http://MobileDev.TW
區分各別自定圖標
2.  利用MKPinAnnotationView的reuseIdentifier來
    區分是哪一個圖標被按下




          Map&GPS   24   http://MobileDev.TW
5.Lab小圖示
•  在彈出視窗中加入小圖示




      Map&GPS      25   http://MobileDev.TW
小圖示
在viewForAnnotation方法中的MKPinAnnotationView
  中設定leftCalloutAccessoryView屬性




          Map&GPS   26   http://MobileDev.TW
6.客製化圖標影像




Map&GPS   27   http://MobileDev.TW
客製化圖標影像
1.  新建檔案,繼承自MKAnnotationView




        Map&GPS   28   http://MobileDev.TW
客製化圖標影像
2.  實作時,使用輸入的圖片,加至目前畫面




      Map&GPS   29   http://MobileDev.TW
客製化圖標影像
3.  回到viewForAnnotation,不使
    用MKPinAnnotationView,改採用剛才自定
    的CSImageAnnotationView




         Map&GPS   30   http://MobileDev.TW
導航(iOS6 – Apple Map)




 Map&GPS   31   http://MobileDev.TW
7.從目前的位置導航到特定位置
•  設定目的地位置相關資訊




•  開啟Apple Map,從目前位置導航至該位置




       Map&GPS   32   http://MobileDev.TW
Thank you


Map&GPS   http://MobileDev.TW

More Related Content

Viewers also liked

2009/2010 U.S. Strategic Rewards Report by Watson Wyatt
2009/2010 U.S. Strategic Rewards Report by Watson Wyatt2009/2010 U.S. Strategic Rewards Report by Watson Wyatt
2009/2010 U.S. Strategic Rewards Report by Watson Wyatthoustoncomp
 
Catalogue of Beijing Gold Trust
Catalogue of Beijing Gold TrustCatalogue of Beijing Gold Trust
Catalogue of Beijing Gold Trust华 刘
 
Dvd paino loris_lliterastoni
Dvd paino loris_lliterastoniDvd paino loris_lliterastoni
Dvd paino loris_lliterastoniLooriiSPA
 
Pengembangan profeis guru dewil vi indra, s.pd, sma 15 merangin
Pengembangan profeis guru dewil vi indra, s.pd,  sma 15 meranginPengembangan profeis guru dewil vi indra, s.pd,  sma 15 merangin
Pengembangan profeis guru dewil vi indra, s.pd, sma 15 meranginMaryanto Sumringah SMA 9 Tebo
 
Why We Should Avoid Using Plastic Bags
Why We Should Avoid Using Plastic BagsWhy We Should Avoid Using Plastic Bags
Why We Should Avoid Using Plastic Bagsluvarne
 
Edgar Allan Poe. "The Raven"
Edgar Allan Poe. "The Raven"Edgar Allan Poe. "The Raven"
Edgar Allan Poe. "The Raven"TOBM Ternopil
 
Створюємо гармонію та успіх
Створюємо гармонію та успіхСтворюємо гармонію та успіх
Створюємо гармонію та успіхTOBM Ternopil
 
Effects Of Industrial Emissions
Effects Of Industrial EmissionsEffects Of Industrial Emissions
Effects Of Industrial Emissionsluvarne
 

Viewers also liked (20)

2009/2010 U.S. Strategic Rewards Report by Watson Wyatt
2009/2010 U.S. Strategic Rewards Report by Watson Wyatt2009/2010 U.S. Strategic Rewards Report by Watson Wyatt
2009/2010 U.S. Strategic Rewards Report by Watson Wyatt
 
Catalogue of Beijing Gold Trust
Catalogue of Beijing Gold TrustCatalogue of Beijing Gold Trust
Catalogue of Beijing Gold Trust
 
Jing presentation
Jing presentationJing presentation
Jing presentation
 
Dvd paino loris_lliterastoni
Dvd paino loris_lliterastoniDvd paino loris_lliterastoni
Dvd paino loris_lliterastoni
 
NAFTA Paper Part 1
NAFTA Paper Part 1NAFTA Paper Part 1
NAFTA Paper Part 1
 
Pengembangan profeis guru dewil vi indra, s.pd, sma 15 merangin
Pengembangan profeis guru dewil vi indra, s.pd,  sma 15 meranginPengembangan profeis guru dewil vi indra, s.pd,  sma 15 merangin
Pengembangan profeis guru dewil vi indra, s.pd, sma 15 merangin
 
CCSA Certificate1
CCSA Certificate1CCSA Certificate1
CCSA Certificate1
 
IPSO
IPSOIPSO
IPSO
 
Dh9ch07stemchangepreterite
Dh9ch07stemchangepreteriteDh9ch07stemchangepreterite
Dh9ch07stemchangepreterite
 
Why We Should Avoid Using Plastic Bags
Why We Should Avoid Using Plastic BagsWhy We Should Avoid Using Plastic Bags
Why We Should Avoid Using Plastic Bags
 
Edgar Allan Poe. "The Raven"
Edgar Allan Poe. "The Raven"Edgar Allan Poe. "The Raven"
Edgar Allan Poe. "The Raven"
 
Створюємо гармонію та успіх
Створюємо гармонію та успіхСтворюємо гармонію та успіх
Створюємо гармонію та успіх
 
Dh9 ch07 demonstrative
Dh9 ch07 demonstrativeDh9 ch07 demonstrative
Dh9 ch07 demonstrative
 
Tugas akhir
Tugas akhirTugas akhir
Tugas akhir
 
Akreditasi sekolah madrasah
Akreditasi sekolah madrasahAkreditasi sekolah madrasah
Akreditasi sekolah madrasah
 
Memahami Proses Produksi Berita
Memahami Proses Produksi BeritaMemahami Proses Produksi Berita
Memahami Proses Produksi Berita
 
Penegakan Etika dan Hukum di Lingkungan AJI
Penegakan Etika dan Hukum di Lingkungan AJIPenegakan Etika dan Hukum di Lingkungan AJI
Penegakan Etika dan Hukum di Lingkungan AJI
 
Effects Of Industrial Emissions
Effects Of Industrial EmissionsEffects Of Industrial Emissions
Effects Of Industrial Emissions
 
TATA CARA SKPD
TATA CARA SKPDTATA CARA SKPD
TATA CARA SKPD
 
variasi dan jenis bahasa
variasi dan jenis bahasavariasi dan jenis bahasa
variasi dan jenis bahasa
 

Similar to iOS Map and Location

再接再勵學 Swift 程式設計
再接再勵學 Swift 程式設計再接再勵學 Swift 程式設計
再接再勵學 Swift 程式設計政斌 楊
 
05 MapKit and Text Input
05 MapKit and Text Input05 MapKit and Text Input
05 MapKit and Text InputTom Fan
 
Google maps Javascript API v3
Google maps Javascript API v3Google maps Javascript API v3
Google maps Javascript API v3Ryan Chung
 
怎樣在 Flutter app 中使用 Google Maps
怎樣在 Flutter app 中使用 Google Maps怎樣在 Flutter app 中使用 Google Maps
怎樣在 Flutter app 中使用 Google MapsWeizhong Yang
 
iOS App 開發 -- Storybard 基礎練習、APP 上架、IAP
iOS App 開發 -- Storybard 基礎練習、APP 上架、IAPiOS App 開發 -- Storybard 基礎練習、APP 上架、IAP
iOS App 開發 -- Storybard 基礎練習、APP 上架、IAPMing-Sian Lin
 
Study mapapi v0.1
Study mapapi v0.1Study mapapi v0.1
Study mapapi v0.1Paul Yang
 
08 Notification and Rotation
08 Notification and Rotation08 Notification and Rotation
08 Notification and RotationTom Fan
 
以HTML5和COIMOTION打造跨平台App
以HTML5和COIMOTION打造跨平台App以HTML5和COIMOTION打造跨平台App
以HTML5和COIMOTION打造跨平台AppBen Lue
 
高中B1地圖投影判讀 操作學習單
高中B1地圖投影判讀 操作學習單高中B1地圖投影判讀 操作學習單
高中B1地圖投影判讀 操作學習單Deborah Wang
 
Android基礎課程3 - APP上架、廣告與 Facebook 登入
Android基礎課程3 - APP上架、廣告與 Facebook 登入Android基礎課程3 - APP上架、廣告與 Facebook 登入
Android基礎課程3 - APP上架、廣告與 Facebook 登入Duran Hsieh
 

Similar to iOS Map and Location (12)

再接再勵學 Swift 程式設計
再接再勵學 Swift 程式設計再接再勵學 Swift 程式設計
再接再勵學 Swift 程式設計
 
05 MapKit and Text Input
05 MapKit and Text Input05 MapKit and Text Input
05 MapKit and Text Input
 
Google maps Javascript API v3
Google maps Javascript API v3Google maps Javascript API v3
Google maps Javascript API v3
 
怎樣在 Flutter app 中使用 Google Maps
怎樣在 Flutter app 中使用 Google Maps怎樣在 Flutter app 中使用 Google Maps
怎樣在 Flutter app 中使用 Google Maps
 
iOS App 開發 -- Storybard 基礎練習、APP 上架、IAP
iOS App 開發 -- Storybard 基礎練習、APP 上架、IAPiOS App 開發 -- Storybard 基礎練習、APP 上架、IAP
iOS App 開發 -- Storybard 基礎練習、APP 上架、IAP
 
I os 07
I os 07I os 07
I os 07
 
Study mapapi v0.1
Study mapapi v0.1Study mapapi v0.1
Study mapapi v0.1
 
08 Notification and Rotation
08 Notification and Rotation08 Notification and Rotation
08 Notification and Rotation
 
I os 10
I os 10I os 10
I os 10
 
以HTML5和COIMOTION打造跨平台App
以HTML5和COIMOTION打造跨平台App以HTML5和COIMOTION打造跨平台App
以HTML5和COIMOTION打造跨平台App
 
高中B1地圖投影判讀 操作學習單
高中B1地圖投影判讀 操作學習單高中B1地圖投影判讀 操作學習單
高中B1地圖投影判讀 操作學習單
 
Android基礎課程3 - APP上架、廣告與 Facebook 登入
Android基礎課程3 - APP上架、廣告與 Facebook 登入Android基礎課程3 - APP上架、廣告與 Facebook 登入
Android基礎課程3 - APP上架、廣告與 Facebook 登入
 

More from Ryan Chung

Voice-First Games for Alexa
Voice-First Games for AlexaVoice-First Games for Alexa
Voice-First Games for AlexaRyan Chung
 
AI Service Integration - Education
AI Service Integration - EducationAI Service Integration - Education
AI Service Integration - EducationRyan Chung
 
AI Service Integration
AI Service IntegrationAI Service Integration
AI Service IntegrationRyan Chung
 
AI Adoption in the Enterprise
AI Adoption in the EnterpriseAI Adoption in the Enterprise
AI Adoption in the EnterpriseRyan Chung
 
Intro to Dialogflow Chatbot Development
Intro to Dialogflow Chatbot DevelopmentIntro to Dialogflow Chatbot Development
Intro to Dialogflow Chatbot DevelopmentRyan Chung
 
AI in Classroom
AI in ClassroomAI in Classroom
AI in ClassroomRyan Chung
 
AWS re:Invent 2018 Recap
AWS re:Invent 2018 RecapAWS re:Invent 2018 Recap
AWS re:Invent 2018 RecapRyan Chung
 
Service Integration Workshop
Service Integration WorkshopService Integration Workshop
Service Integration WorkshopRyan Chung
 
Smart Home Intro Lab
Smart Home Intro LabSmart Home Intro Lab
Smart Home Intro LabRyan Chung
 
Introduction to DialogFlow
Introduction to DialogFlow Introduction to DialogFlow
Introduction to DialogFlow Ryan Chung
 
Conversational AI Orientation
Conversational AI OrientationConversational AI Orientation
Conversational AI OrientationRyan Chung
 
Udacity Meet Up - 0413
Udacity Meet Up - 0413Udacity Meet Up - 0413
Udacity Meet Up - 0413Ryan Chung
 
Amazon Alexa Development Part II
Amazon Alexa Development Part IIAmazon Alexa Development Part II
Amazon Alexa Development Part IIRyan Chung
 
Amazon Alexa Development
Amazon Alexa DevelopmentAmazon Alexa Development
Amazon Alexa DevelopmentRyan Chung
 
Microsoft Professional Program - AI
Microsoft Professional Program - AIMicrosoft Professional Program - AI
Microsoft Professional Program - AIRyan Chung
 
AI Service Integration
AI Service IntegrationAI Service Integration
AI Service IntegrationRyan Chung
 
Hour of Code - Amazon Alexa
Hour of Code - Amazon AlexaHour of Code - Amazon Alexa
Hour of Code - Amazon AlexaRyan Chung
 

More from Ryan Chung (20)

Voice-First Games for Alexa
Voice-First Games for AlexaVoice-First Games for Alexa
Voice-First Games for Alexa
 
AI Service Integration - Education
AI Service Integration - EducationAI Service Integration - Education
AI Service Integration - Education
 
AI Service Integration
AI Service IntegrationAI Service Integration
AI Service Integration
 
AI Adoption in the Enterprise
AI Adoption in the EnterpriseAI Adoption in the Enterprise
AI Adoption in the Enterprise
 
Intro to Dialogflow Chatbot Development
Intro to Dialogflow Chatbot DevelopmentIntro to Dialogflow Chatbot Development
Intro to Dialogflow Chatbot Development
 
AI in Classroom
AI in ClassroomAI in Classroom
AI in Classroom
 
AWS re:Invent 2018 Recap
AWS re:Invent 2018 RecapAWS re:Invent 2018 Recap
AWS re:Invent 2018 Recap
 
MovieBot
MovieBotMovieBot
MovieBot
 
Service Integration Workshop
Service Integration WorkshopService Integration Workshop
Service Integration Workshop
 
MPP AI
MPP AIMPP AI
MPP AI
 
Smart Home Intro Lab
Smart Home Intro LabSmart Home Intro Lab
Smart Home Intro Lab
 
Introduction to DialogFlow
Introduction to DialogFlow Introduction to DialogFlow
Introduction to DialogFlow
 
Conversational AI Orientation
Conversational AI OrientationConversational AI Orientation
Conversational AI Orientation
 
Udacity Meet Up - 0413
Udacity Meet Up - 0413Udacity Meet Up - 0413
Udacity Meet Up - 0413
 
Amazon Alexa Development Part II
Amazon Alexa Development Part IIAmazon Alexa Development Part II
Amazon Alexa Development Part II
 
Amazon Alexa Development
Amazon Alexa DevelopmentAmazon Alexa Development
Amazon Alexa Development
 
Microsoft Professional Program - AI
Microsoft Professional Program - AIMicrosoft Professional Program - AI
Microsoft Professional Program - AI
 
AI Service Integration
AI Service IntegrationAI Service Integration
AI Service Integration
 
Intro to AI
Intro to AIIntro to AI
Intro to AI
 
Hour of Code - Amazon Alexa
Hour of Code - Amazon AlexaHour of Code - Amazon Alexa
Hour of Code - Amazon Alexa
 

iOS Map and Location