Google Maps for Work客户端ID和签名

时间:2015-09-02 14:37:18

标签: gmlib

我们已经在我们的Delphi 2007应用程序中实现了优秀的GMLib库,一切正常。我们需要使用Google Maps for Work许可证(并且需要增加的配额)。我们不知道如何在底层JavaScript中实现它。

不幸的是,GMLib的作者最近的活动并不多。有谁知道他们是否会在(近)未来支持这个代码?

1 个答案:

答案 0 :(得分:0)

Eventually we found the answer to this ourselves:

  1. The map.html in the Resources folder need changing from API_KEY to client

    src="http://maps.google.com/maps/api/js?v=3.17&key=API_KEY&etc.
    
    src="http://maps.google.com/maps/api/js?v=3.17&client=API_KEY&etc.
    

and the resource file needs rebuilding

  1. The GMMap.APIKey can now be set to the client id (issued by Google, in the form gme-myclientid. Google also require referrer URLs to be registered on the client portal, it is the combination of the client id and referrer URL that gets access

  2. (the important bit) GMMapVCL.pas needs updating

    procedure TGMMap.LoadBlankPage;
    begin
      if not (FWebBrowser is TWebBrowser) then Exit;
    
      FDocLoaded := False;
      //TWebBrowser(FWebBrowser).Navigate('about:blank');
      TWebBrowser(FWebBrowser).HandleNeeded;
      TWebBrowser(FWebBrowser).Navigate('http://myvalidreferrerurl');
    end;
    

It may be possible to register about.blank as a valid referrer URL, but that would effectively open access to anyone who knew the client id. Instead, make sure that there is no document on the TWebBrowser control when loading GMMap, which will cause the above procedure to be run.