iT邦幫忙

2017 iT 邦幫忙鐵人賽
DAY 10
0
Cloud

Xamarin.Forms, ASP.NET Core WEB API搭配AZURE的網站服務與資料庫服務整合應用實例系列 第 29

Day29 – Xamarin.Forms整合Google Map顯示打卡資料 Part1

  • 分享至 

  • twitterImage
  •  

最後來到顯示打卡資料的關卡, 想要結合Google Map呈現打卡地點, 必須借助Plugin, 搜尋了一下日本大神amay077開發了一個Google Map的Plugin給Xamarin.Form使用, 位置如下
https://github.com/amay077/Xamarin.Forms.GoogleMaps

不過要在IOS中使用Google Map, 必須先去申請API KEY後, 才能使用, 位置如下
https://developers.google.com/maps/documentation/ios-sdk/

點選GET A KEY
http://ithelp.ithome.com.tw/upload/images/20170113/20103333MSu2xEPfXY.png

接著Select project與勾選Yes
http://ithelp.ithome.com.tw/upload/images/20170113/20103333eln9x0b4Nx.png

由於Day19已經申請過一個Android專案, 所以直接選這個專案來用, 然後按下ENABLE API
http://ithelp.ithome.com.tw/upload/images/20170113/20103333lBwf9rqu0V.png

接著會看到API KEY, 把它複製出來, 等等會用到
http://ithelp.ithome.com.tw/upload/images/20170113/2010333314pR2pHJfK.png

在NuGet搜尋Xamarin.Forms.GoogleMaps然後安裝
http://ithelp.ithome.com.tw/upload/images/20170113/20103333SM9TiLth2c.png

打開IOS專案下的AppDelegate.cs, 插入底下程式碼, 並把剛剛申請的Google API KEY填上, 如底下紅框所示
Xamarin.FormsGoogleMaps.Init("API KEY");
http://ithelp.ithome.com.tw/upload/images/20170113/20103333s4lwG0uJrX.png

然後新增一個CheckInDetailPage.xaml
http://ithelp.ithome.com.tw/upload/images/20170113/20103333Mm3BBn4XB0.png

打開CheckInDetailPage.xaml, 程式碼修改如下
http://ithelp.ithome.com.tw/upload/images/20170113/20103333phWg3RHwCQ.png

打開CheckInDetailPage.xaml.cs, 程式碼修改如下
http://ithelp.ithome.com.tw/upload/images/20170113/20103333Kme3i04V8O.png
http://ithelp.ithome.com.tw/upload/images/20170113/20103333Uih87U8OXy.png
http://ithelp.ithome.com.tw/upload/images/20170113/20103333NqyDR38NvF.png

然後就可以進行測試了, 不過這個Google Map Plugin在模擬器是跑不起來的, 所以直接實機測試
完成畫面如下
http://ithelp.ithome.com.tw/upload/images/20170113/20103333MRQdkLUAFh.png

但是Show Photo功能沒作用, 出現底下錯誤
http://ithelp.ithome.com.tw/upload/images/20170113/20103333yWS8nkEtoF.png

真是滿滿的大崩潰/images/emoticon/emoticon70.gif, 原因好像出在底下Method沒實作
http://ithelp.ithome.com.tw/upload/images/20170113/20103333TXo3S1qsXc.png

今天無力再戰, 明天以解決這個做完結篇好了

後記: 微軟你是做半套嗎?/images/emoticon/emoticon09.gif上傳ok但是下載沒有, 還是故意搞Xamarin呢?因為同樣的Method, 在WEP API是OK的


上一篇
Day28 – Xamarin.Forms新增打卡資料 Part2加入拍照上傳與相簿上傳功能
下一篇
Day30 – Xamarin.Forms整合Google Map顯示打卡資料 Part2 Azure共用存取簽章 (SAS)
系列文
Xamarin.Forms, ASP.NET Core WEB API搭配AZURE的網站服務與資料庫服務整合應用實例32
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言