2

Has anyone had any success getting StreetView to display in a TWebBrowser control?

I want to build a Url programmatically and have it display in a simple Delphi form.

Here's what I have so far for that form:

unit frmSView;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, OleCtrls, SHDocVw, StdCtrls;

type
  TfrmStreetView = class(TForm)
    browserStreetView: TWebBrowser;
    txtAddress: TEdit;
    procedure txtAddressExit(Sender: TObject);
    procedure ShowSV(Lat: string; Lon: string);
  private
    // private declarations
  public
    // public declarations
  end;

var
  frmStreetView: TfrmStreetView;

implementation

{$R *.dfm}

procedure TfrmStreetView.ShowSV(Lat: string; Lon: string);
var
  Addr: string;
  Flags: OleVariant;
begin
  Addr := 'http://maps.google.com/maps?q=&&layer=c&&cbll=' + Lat + ',' + Lon + '&&cbp=12,0,0,0,0&&output=svembed';
  browserStreetView.Navigate(Addr, Flags, Flags, Flags, Flags);
  txtAddress.Text := Addr;
  ShowModal;
end;

procedure TfrmStreetView.txtAddressExit(Sender: TObject);
var
  Flags: OleVariant;
begin
  browserStreetView.Navigate(txtAddress.Text, Flags, Flags, Flags, Flags);
end;

end.

When the form shows:

  • if there is no street view information at that location, I get a regular map view.
  • If there is street view information (verified in another browser window), it just displays a grey screen.

I'm guessing that the Flash player is not loading.

Do you guys have any ideas?

Regards,

Simon

nouns
  • 41
  • 9

2 Answers2

5

Have you looked at the DelphiMaps project? Description:

The DelphiMaps library is a set of Delphi components that aim to make it easy for developers to incorporate GIS functionality in their applications.

The package contains wrappers for:

  • Google Maps API (v3)
  • Google/Openstreetmap Static Maps
  • Google Geocoding API
  • Google Directions API
  • Google StreetView

Rodrigo Ruz posted a fully functional example on his blog in 2010.

Rob Kennedy
  • 161,384
  • 21
  • 275
  • 467
RBA
  • 12,337
  • 16
  • 79
  • 126
  • That looks really good but I'm restricted to Delphi 2006 which is struggling to load it :( – nouns Jul 09 '12 at 14:25
  • No, I can't get the project to load without errors. I probably need to reference some packages (?) somewhere but I'm pretty new to Delphi and a bit lost at the moment. I've loaded the DemoStreetView project and it can't find DelphiMaps.Browser.dcu. – nouns Jul 09 '12 at 14:42
  • 1
    @nouns You have to install the package which came with this library, most likely. I haven't looked, but I'm very willing to bet it has a package which you need to install, which places components in your palette. Only then can you open the sample projects, or otherwise use this library. There should probably be some instructions with the library, but if not, then look into how to install a component package. – Jerry Dodge Jul 10 '12 at 00:18
3

It's been a long time since I wrote anything with Delphi but if I remember correctly, the TWebBrowser control is the browser part of whatever version of Internet Explorer you have on your system. The "browser part" means the HTML renderer and the Javascript interpreter, but the complete program called Internet Explorer is more than that. It also has plugins, such as Flash, and some management logic to load those plugins when needed.

What I'd suggest is that instead of loading maps.google.com you could create a simple page with the V3 API which implements streetview without Flash, (pure Javascript). Try loading this page into your TWebBrowser control and then just drop the pegman somewhere nice:

http://maps.forum.nu/v3/gm_streetview_V3.html

Marcelo
  • 9,387
  • 3
  • 35
  • 40
  • 2
    +1ed, @nouns, be careful when you're going to create your `TfrmStreetView` several times due to [`this problem`](http://stackoverflow.com/q/9518594/960757). – TLama Jul 09 '12 at 20:52