unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, SHDocVw,
gmAPI, gmMap, gmBase, gmOverlaysMarker;
type
TForm1 = class(TForm)
WebBrowser1: TWebBrowser;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
procedure InitMap(Sender: TObject);
procedure MakeMarker;
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
MakeMarker; // läuft ohne Probleme!
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
if Script=nil then with TScript.Create(WebBrowser1) do LoadAPIAsync(InitMap);
// MakeMarker; // stürzt ab!
end;
procedure TForm1.InitMap(Sender: TObject);
var MyOptions : TMapOptions;
begin
with Sender as TScript do begin
MyOptions := TMapOptions.Create;
with MyOptions do begin
Zoom := 12;
Center := New(Google.Maps.LatLng(51.250249, 9.835209));
StreetViewControl := False;
MapTypeID := Google.Maps.MapTypeID.Roadmap;
end;
New(Google.Maps.Map(MyOptions));
end;
end;
procedure TForm1.MakeMarker;
var MarkerOptions : TMarkerOptions;
begin
with Script(WebBrowser1) do begin
MarkerOptions := TMarkerOptions.Create;
with MarkerOptions do begin
Position := New(Google.Maps.LatLng(51.250249, 9.835209));
Map := Maps[0];
end;
New(Google.Maps.Marker(MarkerOptions));
MarkerOptions.Free;
end;
end;
end.