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.
in this sample application you can use the traffic layer , Bicycling layer and the street View Control to activate the panorama view.
for additional info about the Google maps api v3 you can check these links.
Check the next full commented sample application written in Delphi 2007, the source code is available in this
location
006 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, |
007 | Dialogs, OleCtrls, SHDocVw, StdCtrls, ExtCtrls, XPMan, ComCtrls,MSHTML; |
010 | TfrmMain = class (TForm) |
011 | WebBrowser1: TWebBrowser; |
012 | LabelAddress: TLabel; |
014 | ButtonGotoLocation: TButton; |
015 | XPManifest1: TXPManifest; |
017 | ButtonGotoAddress: TButton; |
018 | LabelLatitude: TLabel; |
019 | LabelLongitude: TLabel; |
022 | CheckBoxTraffic: TCheckBox; |
023 | CheckBoxBicycling: TCheckBox; |
024 | CheckBoxStreeView: TCheckBox; |
025 | procedure FormCreate(Sender: TObject); |
026 | procedure ButtonGotoAddressClick(Sender: TObject); |
027 | procedure ButtonGotoLocationClick(Sender: TObject); |
028 | procedure CheckBoxTrafficClick(Sender: TObject); |
029 | procedure CheckBoxBicyclingClick(Sender: TObject); |
030 | procedure CheckBoxStreeViewClick(Sender: TObject); |
033 | HTMLWindow2: IHTMLWindow2; |
124 | procedure TfrmMain . FormCreate(Sender: TObject); |
126 | aStream : TMemoryStream; |
128 | WebBrowser1 . Navigate( 'about:blank' ); |
129 | if Assigned(WebBrowser1 . Document) then |
131 | aStream := TMemoryStream . Create; |
133 | aStream . WriteBuffer( Pointer (HTMLStr)^, Length(HTMLStr)); |
135 | aStream . Seek( 0 , soFromBeginning); |
136 | (WebBrowser1 . Document as IPersistStreamInit).Load(TStreamAdapter . Create(aStream)); |
140 | HTMLWindow2 := (WebBrowser1 . Document as IHTMLDocument2).parentWindow; |
144 | procedure TfrmMain . ButtonGotoLocationClick(Sender: TObject); |
146 | HTMLWindow2 . execScript(Format( 'GotoLatLng(%s,%s)' ,[Latitude . Text,Longitude . Text]), 'JavaScript' ); |
149 | procedure TfrmMain . ButtonGotoAddressClick(Sender: TObject); |
153 | address := MemoAddress . Lines . Text; |
154 | address := StringReplace(StringReplace(Trim(address), # 13 , ' ' , [rfReplaceAll]), # 10 , ' ' , [rfReplaceAll]); |
155 | HTMLWindow2 . execScript(Format( 'codeAddress(%s)' ,[QuotedStr(address)]), 'JavaScript' ); |
158 | procedure TfrmMain . CheckBoxStreeViewClick(Sender: TObject); |
160 | if CheckBoxStreeView . Checked then |
161 | HTMLWindow2 . execScript( 'StreetViewOn()' , 'JavaScript' ) |
163 | HTMLWindow2 . execScript( 'StreetViewOff()' , 'JavaScript' ); |
167 | procedure TfrmMain . CheckBoxBicyclingClick(Sender: TObject); |
169 | if CheckBoxBicycling . Checked then |
170 | HTMLWindow2 . execScript( 'BicyclingOn()' , 'JavaScript' ) |
172 | HTMLWindow2 . execScript( 'BicyclingOff()' , 'JavaScript' ); |
175 | procedure TfrmMain . CheckBoxTrafficClick(Sender: TObject); |
177 | if CheckBoxTraffic . Checked then |
178 | HTMLWindow2 . execScript( 'TrafficOn()' , 'JavaScript' ) |
180 | HTMLWindow2 . execScript( 'TrafficOff()' , 'JavaScript' ); |
Source
comments