Baidu Map API

Source: Internet
Author: User

Introducing JS

<script type= "Text/javascript" src= " F2b7da9b79e6a33c4b927285590eef97 "></script>
<script type= "Text/javascript" src= "Http://" ></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 (' 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 ("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


Baidu Map API

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.