Window > Android SDK Manager
1. ) 要把library import進來
3. 在Application的Manifest檔裡作設定
接下來就是把 Key 放進應用程式中.打開 AndroidManifest.xml 檔, 選擇 Application Tab,Add -> Meta Data, 在 Name 欄位填入 "com.google.android.maps.v2.API_KEY", 在 Value 欄位填入剛才複製的 API Key 。
選擇 Permissions Tab, Add -> Permission, 在 Name 欄位填入"

題外話: 透過這個Google Play services APK 似乎有與server端連線, 否則怎麼能update new APIs?
再說連線方式猜測應該是類似推播方式, 註冊完等需要update時喚起手機端service APK對應function到server update?
如果Google Play services APK不大改interface, 開發者應該不會太痛苦才是
又發現Google Play services囊括Google+, map等服務, 這會不會很痴肥阿!?
不過這些服務都已經整合OAuth2相當方便阿
運作方式如下圖

1. ) 要把library import進來

2. ) project就在當初ADT下載回來的資料夾底下
(/sdk/extras/google/google_play_service)
(/sdk/extras/google/google_play_service)

3. ) import 進來的GooglePlay library 記得要build過!
確定在google_play_services_lib/bin/google-play-services_lib.jar是存在的
不然我們用到google map的專案會發生import path的error!
4. ) Build Target要記得換成Google APIs喔!!
確定在google_play_services_lib/bin/google-play-services_lib.jar是存在的
不然我們用到google map的專案會發生import path的error!
4. ) Build Target要記得換成Google APIs喔!!

2. 取得API key
1. ) 左側欄 > Services

Note: The Google Maps Android API v2 uses a new system of managing keys. Existing keys from a Google Maps Android v1 application, commonly known as MapView, will not work with the v2 API.
2. ) SHA1 key也不用開console辛苦尋找了
ADT > Preferences > Android > Build
Bingo! 裡頭的SHA1 fingerprint就是我們要的!

若是真要從console取得
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
在填key的時候別忘了尾巴要加上package name! (SHA1 fingerprint);com.example

3. 在Application的Manifest檔裡作設定


com.tonycube.googlemapdemo.permission.MAPS_RECEIVE", 綠色部份請換成你的套件名稱. Protection level 欄位請選擇"signature".
再次 Add -> Uses Permission, 在 Name 欄位填入 "com.tonycube.googlemapdemo.permission.MAPS_RECEIVE", 一樣綠色部份換成你的套件名稱.
4. 把map元件拉進application 開始happy coding吧:)
下面是這版地圖的特色:
- 地圖封裝在 MapFragment 類別中。
- 由於地圖封裝在 MapFragment 類別中,你可以延伸標準的 Activity,而不是切換 MapActivity。
- 使用vector tiles技術可以使地圖顯示得更快,頻寬使用的更少。
- Caching 比較少,所以看到的地圖空白區域會更少。
- 可以顯示3D及透視(室內)地圖。
Paul也開始寫Android app了喔?
回覆刪除混口飯吃, 從頭摸起, 有問題還要請教你呢~
回覆刪除