

HTMLWindow2.execScript('TrafficOn()', 'JavaScript')//Activate the Traffic View option Procedure TfrmMain.CheckBoxTrafficClick(Sender: TObject) HTMLWindow2.execScript('BicyclingOff()', 'JavaScript') //Deactivate the Bicycling View option HTMLWindow2.execScript('BicyclingOn()', 'JavaScript')//Activate the Bicycling View option Procedure TfrmMain.CheckBoxBicyclingClick(Sender: TObject) HTMLWindow2.execScript('StreetViewOff()', 'JavaScript') //Deactivate the Street View option HTMLWindow2.execScript('StreetViewOn()', 'JavaScript') //Activate the Street View option Procedure TfrmMain.CheckBoxStreeViewClick(Sender: TObject) HTMLWindow2.execScript(Format('codeAddress(%s)',), 'JavaScript') //Call the function codeAddress to go the address Procedure TfrmMain.ButtonGotoAddressClick(Sender: TObject) Īddress := StringReplace(StringReplace(Trim(address), #13, ' ', ), #10, ' ', ) HTMLWindow2.execScript(Format('GotoLatLng(%s,%s)',), 'JavaScript') //Call the function GotoLatLng to go the coordinates Procedure TfrmMain.ButtonGotoLocationClick(Sender: TObject) HTMLWindow2 := (WebBrowser1.Document as IHTMLDocument2).parentWindow //Set the instance of the parentWindow to call the javascripts functions (WebBrowser1.Document as IPersistStreamInit).Load(TStreamAdapter.Create(aStream)) //Load the page from the stream aStream.Write(HTMLStr, Length(HTMLStr)) WebBrowser1.Navigate('about:blank') //Set the location to an empty pageĪStream := TMemoryStream.Create //create a TStem to load the Page from the stringĪStream.WriteBuffer(Pointer(HTMLStr)^, Length(HTMLStr)) //Copy the string to the stream Procedure TfrmMain.FormCreate(Sender: TObject) ' bikeLayer = new () '+ //Create the Bicycling Layer instance ' trafficLayer = new () '+ //Create the traffic Layer instance ' map = new (document.getElementById("map_canvas"), myOptions) '+ ' mapTypeId: '+ //Set the default type map ''+//Declare the globals vars to be used in the javascript functions
Exemplo rest delphi code#
HTMLStr: String = //i put The code for the web page page wich load the google maps in a string const, you can use an external html file too or embed the page in a resource and then load in a stream Procedure CheckBoxStreeViewClick(Sender: TObject) Procedure CheckBoxBicyclingClick(Sender: TObject) Procedure CheckBoxTrafficClick(Sender: TObject)

Procedure ButtonGotoLocationClick(Sender: TObject) Procedure ButtonGotoAddressClick(Sender: TObject)

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,ĭialogs, OleCtrls, SHDocVw, StdCtrls, ExtCtrls, XPMan, ComCtrls,MSHTML
Exemplo rest delphi full#
Exemplo rest delphi update#
The Google Maps Javascript API Version 2 has been officially deprecated, so it’s time to update to the new version 3, this post shows how you can use the new Google maps V3 API from Delphi.
