Groups > Borland > Borland Delphi multimedia > Re: Google maps in Delphi vcl appliation?




Google maps in Delphi vcl appliation?

Google maps in Delphi vcl appliation?
Mon, 3 Dec 2007 15:06:57 -0000
I would like to download and display a map section centered on a latitude
and longitude into a Delphi application. I have seen some articles about how
to import a (Google) map into a web page but this involves a web server and
is not what I want to do.

Is there a way to do this from a 'stand alone' application?

Thanks,
Brian

Post Reply
Re: Google maps in Delphi vcl appliation?
Mon, 3 Dec 2007 16:26:18 -0500
I bookmarked an article that may be of interest.
see: http://www.stevetrefethen.com/blog/MashupOfGoogleMapsAndVCL.aspx



"Brian" <BrianWrigley123@yahoo.com> a écrit dans le message de
news:
47541b93$1@newsgroups.borland.com...
>
> I would like to download and display a map section centered on a latitude
> and longitude into a Delphi application. I have seen some articles about
how
> to import a (Google) map into a web page but this involves a web server
and
> is not what I want to do.
>
> Is there a way to do this from a 'stand alone' application?
>
> Thanks,
> Brian
>
>

Post Reply
Re: Google maps in Delphi vcl appliation?
Mon, 3 Dec 2007 22:42:41 -0000
Thanks for your reply,

Actually I saw this but it is more to do with embedding a map in a web page.

What I hope to be able to do is something much simpler like downloading a
section of a map (centred at a given lat/long) as a bitmap and displaying it
in an image or similar.

Still hoping......

Brian





"rap" <voldemor@laposte.net> wrote in message
news:4754746f$1@newsgroups.borland.com...
> I bookmarked an article that may be of interest.
> see: http://www.stevetrefethen.com/blog/MashupOfGoogleMapsAndVCL.aspx
>
>
>
> "Brian" <BrianWrigley123@yahoo.com> a écrit dans le message
de news:
> 47541b93$1@newsgroups.borland.com...
> >
> > I would like to download and display a map section centered on a
latitude
> > and longitude into a Delphi application. I have seen some articles
about
> how
> > to import a (Google) map into a web page but this involves a web
server
> and
> > is not what I want to do.
> >
> > Is there a way to do this from a 'stand alone' application?
> >
> > Thanks,
> > Brian
> >
> >
>
>

Post Reply
Re: Google maps in Delphi vcl appliation?
Sun, 6 Jan 2008 03:48:41 +0100
This might be helpfull... Thats saves the map into c:\googlemap.html....

procedure TForm1.Button1Click(Sender: TObject);

var _latitude:Real;
    _longitude:Real;

const _zoom = 12; // 12 = city,   8 = region

const GoogleAPIKey = 'your Google API key here'

var _html:TStringlist;
    _oldsep:char;
    _web:TMsWinWeb;

    WebBrowser1: TWebBrowser;

begin
     _web := TMsWinWeb.Create(nil);

    WebBrowser1:= TWebBrowser.Create(Application);
    self.InsertControl(webbrowser1);
    webbrowser1.Left := 1;
    webbrowser1.Left := 1;
    webbrowser1.Width := 640;
    webbrowser1.Height := 480;
    webbrowser1.Show;

     _latitude := _web.WebProvider.Latitude.Trigonometric;
     _longitude := _web.WebProvider.Longitude.Trigonometric;

     _oldsep := DecimalSeparator;
     DecimalSeparator := '.';

     _html := tstringlist.create;

     _html.Add('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Strict//EN"');
     _html.Add(' 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">');
     _html.Add('<html xmlns="http://www.w3.org/1999/xhtml">');
     _html.Add('  <head>');
     _html.Add('    <meta http-equiv="content-type"
content="text/html; 
charset=utf-8"/>');
     _html.Add('    <title>Google Maps JavaScript API
Example</title>');
     _html.Add('    <script 
src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=' +
GoogleAPIKey + 
'"');
     _html.Add('      type="text/javascript"></script>');
     _html.Add('    <script type="text/javascript">');
     _html.Add('    //<![CDATA[');
     _html.Add('    function load() {');
     _html.Add('      if (GBrowserIsCompatible()) {');
     _html.Add('        var map = new 
GMap2(document.getElementById("map"));');
     _html.Add('        map.setCenter(new GLatLng(' + FloatToStr(_latitude) 
+ ',' + FloatToStr(_longitude) + '),' + IntToStr(_zoom) + ');');
     _html.Add('      }');
     _html.Add('    }');
     _html.Add('    //]]>');
     _html.Add('    </script>');
     _html.Add('  </head>');
     _html.Add('  <body onload="load()"
onunload="GUnload()">');
     _html.Add('    <div id="map" style="width: 640px; height:

480px"></div>');
     _html.Add('  </body>');
     _html.Add('</html>');


     _html.SaveToFile('c:\googlemap.html');

      WebBrowser1.Navigate('c:\googlemap.html');

     while webbrowser1.Busy
           do application.processmessages;

     WebBrowser1.Free;
     _html.Free;
     _web.Free;

     deletefile('c:\googlemap.html');
     DecimalSeparator := _oldsep;
end;

DH

"Brian" <BrianWrigley123@yahoo.com> a écrit dans le message de
news: 
47541b93$1@newsgroups.borland.com...
>
> I would like to download and display a map section centered on a latitude
> and longitude into a Delphi application. I have seen some articles about 
> how
> to import a (Google) map into a web page but this involves a web server 
> and
> is not what I want to do.
>
> Is there a way to do this from a 'stand alone' application?
>
> Thanks,
> Brian
>
> 

Post Reply
about | contact