Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
Delphi

Example of using JavaScript for Google maps in the Delphi XE6

the future of starts demands massive productivity

Author: Nikolay M4446

One of the innovations in XE6, it’s a method EvaluateJavaScript in the component TWebBrowser. This method allowing execute JavaScript on the loaded page and add interactivity to our applications.

On the site developers.google.com contains many examples of embedding maps on the page. I chose the example for paving the route from point A to point B. And as an example of execution JavaScript, I define two buttons for showing predefined paths from “Chicago” to “Winona” and from “St Louis” to “Gallup”.

Make a new mobile project and drop on the main form TWebBrowser, TPanel and place two TButton on the TPanel.

For convenience, I create just one more unit uJavaScripts.pas. This unit will contain the HTML code of pages and scripts themselves. Most dreary – copy and past example of code and place it as a constant in our unit. I’ve got to do something like this:

Entire code example is taken from the site Google.
We need load it to the browser. For this event, write this code in the FormCreate

We can run it. It looks on the iPhone 5 as on the picture

After it we add two const

And two event handlers for button

Thats it. Now we can choise peath using HTML conntrols or use predefined paths using buttons.

On the iPhone and Kindle Fire HD its look like this


Coding Boot Camp

Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

Related posts
C++DelphiHow-To'sIDERAD StudioWindows

Windows 10 Apps Development Tutorial for Beginners

C++CodeDatabaseDelphiIDERAD Studio

8 Go-To Resources About Development On Windows

C++CodeDatabaseDelphiIDEInterBaseRAD StudioTech Partner

The Ultimate Cheat Sheet On Windows 10 App Development

DelphiRAD StudioTech Partner

How To Make Facebook Posts From Windows And Mobile Apps

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES