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


What's New for RAD Studio 11

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
News

Announcing the Availability of RAD Studio 11 Alexandria

DelphiNewsRAD Studio

How To Make A Native Cross-Platform App In 30 Seconds

CodeDelphiRAD Studio

Everything You Need For An Awesome Low Code Weather App

DelphiShowcase

How To Become The Ultimate World Anagram Champion!

Leave a Reply

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

IN THE ARTICLES