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:
– |
[crayon-676855aa0850e886158985/] |
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