Embarcadero官方的文件 iOS Tutorials: Delphi iOS Application Development ,對於使用Delphi XE4開發iOS有興趣的朋友,一定得下載下來看看的好文件。
下載網址: http://docs.embarcadero.com/products/rad_studio/radstudioXE4/iOS%20Tutorial%20en.pdf
大型網站架構..net 架構師.rabbitMQ.redis.行動開發.APP開發教學.PHP Laravel開發..net core C# 開發.架構師之路.Delphi開發.資料庫程式.進銷存.餐飲POS系統
Embarcadero官方的文件 iOS Tutorials: Delphi iOS Application Development ,對於使用Delphi XE4開發iOS有興趣的朋友,一定得下載下來看看的好文件。
下載網址: http://docs.embarcadero.com/products/rad_studio/radstudioXE4/iOS%20Tutorial%20en.pdf
示範如果快速使用Delphi XE4開發iOS定位功能的程式
1.建立一個新的FireMonkey Mobile Application
2.選擇 Blank Application 空白類型。
3.新增元件ListBox,將 Align 改為 alTop; GroupingKind 改為 GsGrouped;StyleLookup 改為 transparentlistboxstyle。
4. ListBox按右鍵,Add Item 新增 TListBoxHeader,在裡面新增Label ,屬性 Align 設為 alClient ; StyleLookup 設為 toollabel ; TextAlign 設為 taCenter。
5. 接著新增三個 TListBoxItem,分別是開啟定位、經度、緯度。在開啟定位的右側新增TSwitch開關來開啟定位功能。經度、緯度使用TLabel。
6.接著在畫面上佈置TWebBrowser跟TLocationSensor,TWebBrowser的 Align 設為 alClient。
7.佈置好的畫面如下圖
8. 在Switch1 的 OnSwitch 事件中新增程式如下
[delphi]
procedure TForm1.Switch1Switch(Sender: TObject);
begin
LocationSensor1.Active := Switch1.IsChecked ;
end;
[/delphi]
9.接著在 LocationSensor1 的 OnLocationChange事件中新增程式如下
[delphi]
procedure TForm1.LocationSensor1LocationChanged(Sender: TObject;
const OldLocation, NewLocation: TLocationCoord2D);
const
sGoogleMapURL : String = ‘https://maps.google.com/maps?q=%s,%s&output=embed’;
begin
label3.Text := ‘經度: ‘ + NewLocation.Latitude.ToString;
label2.Text := ‘緯度: ‘ + NewLocation.Longitude.ToString;
WebBrowser1.Navigate(Format(sGoogleMapURL,
[NewLocation.Latitude.ToString,
NewLocation.Longitude.ToString]));
end;
[/delphi]
10.大功告成!我們來看執行結果