Implement winform positioning and winform Positioning
How can I import a map to winform for positioning?
A baidumap.htm from the Internet is a js file.
Add the webBrowser control to form and write the following code in the form loading event:
WebBrowserMap. Url = new Uri (Path. Combine (Application. StartupPath, "BaiDuMap.htm "));
Then run. The corresponding webBrowser control in form can display the content of the js file, that is, Baidu map.
There is such a piece of code in the js File
Function setLocation (x, y, z) {// parameter: latitude and longitude
Var point_Lo = new BMap. Point (x, y );
Map. centerAndZoom (point_Lo, 11 );
Map. addOverlay (new BMap. Marker (point_Lo ));
Var marker = new BMap. Marker (new BMap. Point (x, y); // creates a tag, which is the longitude and latitude of the area to be queried.
Map. addOverlay (marker );
Var content = z + "<br/> longitude:" + x + "<br/> latitude:" + y;
Var infoWindow = new BMap. InfoWindow ("<p style = 'font-size: 14px; '>" + content + "</p> ");
Marker. addEventListener ("click", function () {this. openInfoWindow (infoWindow );});
Is used for positioning.
WebBrowserMap. Document. InvokeScript ("setLocation", new object [] {lon, lat, Name });
To call the positioning code to implement the positioning function.