I need to be able to access the Google Maps API from a non-web application. I see in Google Maps' FAQs that this is possible. However, I cannot find any reference to accessing the API from a PC-based application. Can someone point me in the right direction?
(I want to access the API from a Delphi application, if that helps.)
Thanks in advance.
Some time ago I wrote a series of articles about using the Google maps API v3 from Delphi, basically you need a TWebBrowser component and load an HTML page with the JavaScript code to handle the Google Maps JavaScript API v3
. from here using functions like IHTMLWindow2.execScript and the MSHTML Interfaces you can interact with the JavaScript code and the Google Maps API responses from Delphi.
Also take a look to these projects
If you have serious plans in this direction:
Forget about the Google Maps API, and use OpenLayers instead.
Believe me, I've got hands-on experience with this. I've created countless interactive mapping websites and applications, and I've written code that wrap Google Maps functionality into Delphi components. You can find them on Google code: http://code.google.com/p/delphimaps/
You can also find some example application that I've made with an early version of these components here: Use Googlemap from my Delphi application?
OpenLayers is much more versatile, it's completely open source, and it has a whole community behind it. It can even use Google Maps, but you can easily switch to OpenStreetMaps, Yahoo, Bing, or your own GIS system.
There are many examples online, and you're not tied to stupid rules that are imposed by Google. For example, if you want to use Google Maps via a secure (HTTPS) connection, you have to pay. I never directly use the Google Maps API anymore, and my GIS websites became much better since I started using OpenLayers.
Maybe one day I should wrap OpenLayers into Delphi components, but I now do most stuff in JavaScript instead, and only communicate with my Delphi app when it's really needed, so even with Delphi apps that contain a map, not much GIS stuff is done in Delphi. That turns out to be easier to maintain.
..
Also, OpenLayers doesn't require any internet connection. It can run 100% in your offline browser. Google Maps requires you to have an internet connection, as it downloads parts of its code dynamically, and it always wants to download its maps from Google.
If you are looking for a complete solution to use the Google Maps API with Delphi, I highly recommend the Delphi Framework for Google Maps. It enables to use all API functions without a single line of HTML or JavaScript.
For example:
procedure TForm1.FormShow(Sender: TObject);
begin
with Script(WebBrowser1) do
if not APILoaded
then LoadAPIAsync(InitMap);
end;
procedure TForm1.InitMap(Sender: TObject);
var
MapOptions: TMapOptions;
begin
with Sender as TScript do
begin
MapOptions:=New(Google.Maps.MapOptions);
with MapOptions do
begin
Zoom:=8;
Center:=New(Google.Maps.LatLng(-34.397,150.644));
MapTypeID:=Google.Maps.MapTypeID.Roadmap;
end;
New(Google.Maps.Map(MapOptions));
end;
end;
The route planner is also easily available. There are some demos.
Unfortunately, you must still download it currently from a German forum. A separate website is under construction. If there are problems with the registration or download, I can send an email with the framework.
Regards
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With