ASP.NET MVC use Baidu map

   Before using Baidu map, we have to go to Baidu open platform application ak. Address: http://lbsyun.baidu.com/

 

 Fill developer authentication information, you can as an individual, can also be the name of the company to apply a secret key, business developer certification more powerful. In the pre-made technology development, we usually an individual apply for a secret key, such as the time after the item you want on the line to switch to the corporate keys on it (you can also use the powerful Baidu to find some keys) generally filling out authentication information after that, within three to five business days, the review will, after approval, will be to create the application.

 

With Baidu map generator to generate code, address: http://api.map.baidu.com/lbsapi/creatmap/index.html

The generated code, copy and paste directly into your project page can be used, but the generated code is generated after all, you need to reconstruct themselves.

You can also go to Baidu API samples to look for examples, and then modified, transformed into the way you need. Address: http://developer.baidu.com/map/jsdemo.htm#c1_3

Here is a simple example of what I do, you just copy down, and then put their keys to fill in just fine.

 1 @{
 2     Layout = null;
 3 }
 4 
 5 <!DOCTYPE html>
 6 <html>
 7 <head>
 8     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 9     <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
10     <style type="text/css">
11         body, html, #allmap {
12 is              width: 100 % ;
 13 is              height: 100 % ;
 14              overflow: hidden;
 15              margin: 0 ;
 16              font-Family: " Microsoft yahei " ;
 . 17          }
 18 is      </ style>
 . 19      <title> loaded asynchronously map </ title >
 20 is </ head>
 21 is <body>
 22 is      <div ID = " allmap " > </ div>
 23 is </ body>
 24 </ HTML>
25 <script type="text/javascript">
26     //百度地图API功能
27     function loadJScript() {
28         var script = document.createElement("script");
29         script.type = "text/javascript";
30         script.src = "//api.map.baidu.com/api?v=3.0&ak=PlhFWpA02aoURjAOpnWcRGqw7AI8EEyO&callback=init";
31         document.body.appendChild(script);
32     }
33     function init() {
34         var map = new new BMap.Map ( " allmap " );             // Create Map instance 
35          var Point = new new BMap.Point ( 116.404 , 39.915 ); // Creates a new Point 
36          map.centerAndZoom (Point, 15 );
 37 [          map.enableScrollWheelZoom () ;                  // enable zoom roller 
38 is      }
 39      the window.onload = loadJScript;   // loaded asynchronously map 
40 </ Script>
 41 is  
42 is <HTML>
 43 is <head>
 44 is      <Meta name ="viewport" content="width=device-width" />
45     <title>Map</title>
46 </head>
47 <body>
48     <div>
49     </div>
50 </body>
51 </html>
View Code

It's pretty simple, nothing to talk about, just a little, everyone in the process of writing code, as far as possible not to repeat your code, this is the most basic principles.

In fact, use some third-party API, it is really very simple, you probably only need to first go over the API documentation, know what it can do, and what areas you need to function, and then be dedicated to a closer look at this document and function example, and then change their own shining on it.

 

Guess you like

Origin www.cnblogs.com/qiao298/p/11576422.html