Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Google maps in Delphi vcl appliation?

403 views
Skip to first unread message

Brian

unread,
Dec 3, 2007, 10:06:57 AM12/3/07
to

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


rap

unread,
Dec 3, 2007, 4:26:18 PM12/3/07
to
I bookmarked an article that may be of interest.
see: http://www.stevetrefethen.com/blog/MashupOfGoogleMapsAndVCL.aspx

"Brian" <BrianWr...@yahoo.com> a écrit dans le message de news:
47541b93$1...@newsgroups.borland.com...

Brian

unread,
Dec 3, 2007, 5:42:41 PM12/3/07
to
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" <vold...@laposte.net> wrote in message
news:4754746f$1...@newsgroups.borland.com...

HAROUCHE, David

unread,
Jan 5, 2008, 9:48:41 PM1/5/08
to
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" <BrianWr...@yahoo.com> a écrit dans le message de news:
47541b93$1...@newsgroups.borland.com...
>

0 new messages