Reference yesterday's content, have a friend or ask how to call Baidu map, also, who let us all in the domestic, no way, you understand.
First go to apply for a key, and then look at the first example of Baidu JavaScript: http://developer.baidu.com/map/jsdemo.htm
The next step is to move the code in the example to Twebbrower.
Unit Unit3;
Interface
Uses
System.sysutils, System.types, System.uitypes, system.classes, System.variants,
FMX. Types, FMX. Controls, FMX. Forms, FMX. Graphics, FMX. Dialogs, FMX. WebBrowser,
Fmx.stdctrls;
Type
TFORM3 = Class (Tform)
Webbrowser1:twebbrowser;
Button1:tbutton;
Procedure Formcreate (Sender:tobject);
Procedure Button1Click (Sender:tobject);
Private
{Private declarations}
Public
{Public declarations}
End
Var
FORM3:TFORM3;
Const
S= ';//equal to the content of the Web page, I posted it, it was messy, had to explain here.
s1=
' var map = new Bmap.map ("Allmap"); '
+ ' var point = new Bmap.point (116.404, 39.915); '
+ ' Map.centerandzoom (point,15); '
+ ' map.enablescrollwheelzoom (); '
;//The JavaScript code to execute
Implementation
{$R *.FMX}
Procedure Tform3.button1click (Sender:tobject);
Begin
WebBrowser1. Evaluatejavascript (S1);//execute JavaScript code on the Web page.
End
Procedure Tform3.formcreate (Sender:tobject);
Begin
WebBrowser1. Loadfromstrings (S, ' http://api.map.baidu.com ');//Transfer into web page
End
End.
Note the issue:
1. Only Fmx.webbrowser supports Evaluatejavascript and Loadfromstring methods, and the Twebbrowser of VCL is not supported.
2.FMX. WebBrowser only supports Android IOS and does not support WIN32
3.LoadFromStrings when you call a Web page, you specify the second parameter, or the map is not displayed
Regret:
Feel the map display speed is not good, when you click on the button, will flash, to the performance of the FMX or the reason for this call method generated? It's not clear.
Finally, attach:
Postscript:
Baidu for the mobile phone to provide a dedicated JavaScript API, called fast xxx, I tried to call, not out of the map, do not know what the reason. It is estimated that this will improve the reaction speed.
Http://blog.sina.com.cn/s/blog_44fa172f0101ri82.html
Delphi XE6 calls Baidu map via JavaScript API