Introducing JS
<script type= "Text/javascript" src= "http://api.map.baidu.com/api?v=2.0&ak= F2b7da9b79e6a33c4b927285590eef97 "></script>
<script type= "Text/javascript" src= "Http://developer.baidu.com/map/jsdemo/demo/convertor.js" ></script >//Google coordinates turn Baidu
Common Controls
Control: The abstract base class for controls in which all controls inherit methods, properties of this class. This class enables you to implement a custom control.
Navigationcontrol: The map Pan zoom control , which defaults to the top left side of the map, contains the ability to control the panning and zooming of the map. The mobile side provides a zoom control, which is located by default in the lower right of the map.
Overviewmapcontrol: The thumbnail map control , which is located at the bottom right of the map by default, is a collapsible thumbnail map.
Scalecontrol: A scale control that, by default, is located at the bottom left of the map, showing the map's scale relationship.
Maptypecontrol: The map type control , which is located at the top right of the map by default.
Copyrightcontrol: Copyright Control , which is located at the bottom left of the map by default.
Geolocationcontrol: positioning controls , developed for Mobile, are located at the bottom left of the map by default.
Control to add a method:
New BMap. map("container"); map. Centerandzoom(new BMap. Point(116.40439.915), map. AddControl(new BMap. Navigationcontrol());
1.var MP = new Bmap.map (' Map ');
Mp.centerandzoom (New Bmap.point (121.491, 31.233), 11);//Set center point and scale size
2.var map = new BMap. Map("container");
var point = new BMap. Point(116.404, 39.915);
< Span class= "st0" >< Span class= "me1" >< Span class= "Sy0" >map. centerandzoom (Point15
var marker = new BMap. marker (Point//create callout
map. Addoverlay//add labels to the map
3. /span> /span>
Map. AddEventListener("click"function()alert("You clicked on the map. ")});//The Listener event can also capture the state after the event is triggered by listening for events.
Map. RemoveEventListener("click", Showinfo);//Remove Listener Events
4. Map Coordinate conversion
Baidu Map API Features
Google coordinates
var x = 116.32715863448607;
var y = 39.990912172420714;
var ggpoint = new Bmap.point (x, y);
Map initialization
var bm = new Bmap.map ("Allmap");
Bm.centerandzoom (Ggpoint, 15);
Bm.addcontrol (New Bmap.navigationcontrol ());
callback function after the coordinate conversion is complete
Translatecallback = function (point) {
var marker = new Bmap.marker (point);
Bm.addoverlay (marker);
var label = new Bmap.label ("I am Baidu labeled Oh", {offset:new bmap.size (20,5)});
Marker.setlabel (label); Add Baidu Label
Bm.setcenter (point);
}
BMap.Convertor.translate (ggpoint,2,translatecallback);//gcj-02 coordinates turn into Baidu
5..http://developer.baidu.com/map/jsdemo.htm#a6_1//baidudemo
Baidu Map API