2016-12-02 27 views
-1

我仍然困惑爲什麼我要'TMapView'在第47行不包含名爲'Location'的成員。我也嘗試混合並且與演示代碼示例相匹配,但我不明白髮生了什麼問題。我的猜測是,我需要一個私人或公共的聲明..但我遇到了很多麻煩,試圖找到適當的文件關於它......沒有得到它基本上。請注意,我對Delphi編程完全陌生。'TMapView'不包含名爲'Location'的成員

下面的代碼:

unit MainUnit; 

interface 

uses 
    System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, 
    FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls, 
    FMX.Controls.Presentation, FMX.MultiView, FMX.Layouts, FMX.ExtCtrls, FMX.Maps, 
    FMX.TabControl; 

type 
    TMainForm = class(TForm) 
    MultiView1: TMultiView; 
    MainPanel: TPanel; 
    HeaderPanel: TPanel; 
    Button1: TButton; 
    TabControl1: TTabControl; 
    TabItem1: TTabItem; 
    TabItem2: TTabItem; 
    TabControl2: TTabControl; 
    PrimaryImageViewer: TImageViewer; 
    TabItem3: TTabItem; 
    TabItem4: TTabItem; 
    PrimaryMapView: TMapView; 
    SecondaryMapView: TMapView; 
    SecondaryImageViewer: TImageViewer; 
    Label1: TLabel; 
    procedure FormShow(Sender: TObject); 
    private 
    { Private declarations } 
    public 
    { Public declarations } 
    end; 

var 
    MainForm: TMainForm; 

implementation 

{$R *.fmx} 

procedure MainForm.FormShow(Sender: TObject); 

begin 

    SecondaryMapView.Location := TMapCoordinate.Create(59.965, 30.35); 
    SecondaryMapView.Zoom := 10; 


end; 

end. 
+0

你懂什麼錯誤消息意味着 –

+0

@DavidHeffernan我不明白是什麼意思,但我不明白怎麼解決它。 – exxe

+0

你是否有要交的文件。這有幫助嗎? –

回答

1

Mobile Tutorial: Using a Map Component to Work with Maps (iOS and Android)

您需要添加一個TMapCoordinate變量,從47行刪除Location所以可以先通過值,然後傳遞位置到地圖。在第47行下面添加Location := mapCenter,如下所示,或者查看上面的鏈接。

procedure MainForm.FormShow(Sender: TObject); 
var 
    mapCenter: TMapCoordinate; 
begin 
    mapCenter := TMapCoordinate.Create(59.965, 30.35);//this might be a Float 
    SecondaryMapView.Location := mapCenter; 
    SecondaryMapView.Zoom := 10; 
end; 
+0

我認爲這是我需要的。我不知道要鍵入來添加TMapCoordinate變量。 – exxe

+0

這就是答案,只是還有一個問題......地圖仍然不會自動加載當前用戶的位置,而是自動加載指定的座標。我如何根據用戶的位置默認/自動地檢測當前用戶的位置並將地圖居中? – exxe

相關問題