'TMapView'不包含名为'Location'的成员

时间:2016-12-02 16:51:40

标签: android google-maps delphi firemonkey

我仍然感到困惑,为什么我得到'TMapView'在第47行没有包含名为'Location'的成员。我也尝试混合搭配演示代码示例,但我不明白怎么了。我的猜测是我需要一个私人或公开声明..但是我在寻找有关它的适当文档方面遇到了很多麻烦......基本上没有得到它。请注意我对Delphi编程完全不熟悉。

以下是代码:

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.

1 个答案:

答案 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;