The first contact of Baidu map API and the first contact of map api
Due to project requirements, Baidu API was first introduced.
Step 1: reference the Baidu map API script
If you want to download both the map file and js file in the LAN environment
<script type="text/javascript" src="http://api.map.baidu.com/api?key=*****************&v=1.0&services=false"></script>
You need to go to the Baidu Developer Center to apply for a KEY.
Step 2: Create a div named by you to put the map
<div style="width: 520px; height: 340px; border: 1px solid gray" id="container"></div>
Step 3: use Baidu map API to build a map
// Initialize the map and place the map in the div of step 2.
Var map = new BMap. Map ("container ");
// Determine a point based on the longitude and latitude
Var point = new BMap. Point (116.404, 39.915 );
// This is the point in the map center, and the zoom-in level of the map is set to 15map. centerAndZoom (point, 15 );
// The interface is moved to the center 2 s later to a new window. setTimeout (function () {map. panTo (new BMap. Point (116.409, 39.918);}, 2000 );
// Load some controls on the Interface: Zoom control, scale control, and global control map. addControl (new BMap. navigationControl (); map. addControl (new BMap. scaleControl (); map. addControl (new BMap. overviewMapControl ());
// Add an identifier var marker = new BMap. Marker (point); map. addOverlay (marker );
Step 4: connect to the Internet and open it in a browser