On Baidu's API
<! DOCTYPE html>
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<meta name= "viewport" content= "initial-scale=1.0, User-scalable=no"/>
<style type= "Text/css" >
Body, HTML, #allmap {width:100%;height:100%;overflow:hidden;margin:0;font-family: "Microsoft Jas Black";}
</style>
<script type= "Text/javascript" src= "http://api.map.baidu.com/api?v=2.0&ak= Your Keys" ></script>
<title> ranging </title>
<body>
<div id= "Allmap" ></div>
</body>
<script type= "Text/javascript" >
Baidu Map API Features
var map = new Bmap.map ("Allmap");
Map.centerandzoom ("Chongqing", 12); Initialize the map to set the city and map levels.
var pointa = new Bmap.point (106.486654,29.490295); Create point coordinates a--Dadukou District
var pointb = new Bmap.point (106.581515,29.615467); Create point coordinates b--Jiangbei District
Alert (' Distance from Dadukou District to Jiangbei District: ' + (map.getdistance (POINTA,POINTB) '). ToFixed (2) + ' M. ‘); Get two point distance, keep two decimal places
var polyline = new Bmap.polyline ([Pointa,pointb], {strokecolor: "Blue", Strokeweight:6, strokeopacity:0.5}); Defining polylines
Map.addoverlay (polyline); Add a polyline to the map
function getdistance ()//This is self-added, define a method and then let WinForm call, (of course, can also be reversed, WinForm define a method, JS in the re-call)
{return map.getdistance (POINTA,POINTB). toFixed (2);}
</script>
——————————————————————————————————————————————————————————————————————————————————————
Add Control Webbrower
Adding code to form load
String str_url = Application.startuppath + "\\HTM name. htm"; HTM to be placed in the debug directory, if you do not have to start the directory to put any directory string str_url= ""; do it yourself. Uri url = new Uri (Str_url); Webbrogis.url = URL; Webbrogis.objectforscripting = this;
On WinForm Code
var s = webBrowser1.Document.InvokeScript ("getdistance");//quotation marks are function names, note that variables should be var type
Txtbox.text=s.tostring ();
-----------------------------------------------------------
Several questions 1 garbled to change the charset to gb2312,2 secret key to search online
C#winform and Baidu API Interactive-----Read the parameters of JS