gmlib google maps infowindow error

天涯浪子 提交于 2019-12-11 22:20:03

问题


I use the gmlib V1.4.0 for Delphi Embarcadero XE6. I can create a marker and show them on google maps but when I create a popup for more info (I use GMMarker.InfoWindow.HTMLContent = 'test') then I get an error message after refresh the map.

If I don't open the InfoWindow and refresh the map they will not be the following error. ("Pagina inicial aun no cargada")

What is wrong?

If I do only 'BTN_CreateMarkerClick' and then 'BTN_DoMapClick' they will work but if I call 'BTN_CreateInfoWindowClick' before refresh the map I get an error.

unit DlgGoogleMaps;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, GMMap, GMLinkedComponents,
  GMMarker, GMMarkerVCL, GMClasses, GMMapVCL, Vcl.OleCtrls, SHDocVw, GMConstants,
  Vcl.ExtCtrls, GMGeoCode, GMInfoWindow;

type
  TDlg_GoogleMaps = class(TForm)
    Pan_Bottom: TPanel;
    Web_Box: TWebBrowser;
    GMMap: TGMMap;
    GMMarker: TGMMarker;
    BTN_LoadMap: TButton;
    BTN_CreateMarker: TButton;
    BTN_CreateInfoWindow: TButton;
    BTN_DoMap: TButton;
    GMGeoCode: TGMGeoCode;
    GMInfoWindow: TGMInfoWindow;
    procedure BTN_LoadMapClick(Sender: TObject);
    procedure BTN_CreateMarkerClick(Sender: TObject);
    procedure BTN_CreateInfoWindowClick(Sender: TObject);
    procedure BTN_DoMapClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Dlg_GoogleMaps: TDlg_GoogleMaps;

implementation

{$R *.dfm}

procedure TDlg_GoogleMaps.FormCreate(Sender: TObject);
begin
  Web_Box.Silent := True;
end;

procedure TDlg_GoogleMaps.FormShow(Sender: TObject);
begin
  try
    GMMap.Active := True;
  except
    ShowMessage('Network Error!');
  end;
end;


procedure TDlg_GoogleMaps.BTN_LoadMapClick(Sender: TObject);
begin
  GMMap.DoMap;
end;


procedure TDlg_GoogleMaps.BTN_CreateMarkerClick(Sender: TObject);
var
  point : TMarker;
begin
  point := GMMarker.Add(48.213983, 16.371970, 'TEST');

  point.MarkerType                   := GMConstants.mtstyledmarker;
  point.StyledMarker.BackgroundColor := 16777215;
  point.StyledMarker.TextColor       := 33023;
  point.StyledMarker.StyledIcon      := GMConstants.siBubble;

  GMMap.DoMap;
end;


procedure TDlg_GoogleMaps.BTN_CreateInfoWindowClick(Sender: TObject);
begin
  GMMarker.Items[0].InfoWindow.HTMLContent := 'HELLO';
  GMMarker.Items[0].ShowInfoWinMouseOver   := False;
end;


procedure TDlg_GoogleMaps.BTN_DoMapClick(Sender: TObject);
begin
  // after you open the InfoWindow (PopUp) they will be an error on GMMap.DoMap!??  (<FDocLoaded> ist not activ???)
  // if you don't open the InfoWindow (restart) and the click here they will not be an error. ("Pagina inicial aun no cargada")
  GMMap.DoMap;
end;

end.

来源:https://stackoverflow.com/questions/26467638/gmlib-google-maps-infowindow-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!