JavaScript embedded into Baidu Map

Source: Internet
Author: User

JavaScript embedded into Baidu Map

After applying for the corresponding key on the Baidu map API official website, you can embed Baidu map online in JavaScript.

<Script type = "text/javascript" src = "http://api.map.baidu.com/api? V = 2.0 & ak = Key "> </script>

Create a map instance

Var map = new BMap. Map (); // create a map instance

Show Map

Map = new BMap. map ("map_canvas"); // create a Map instance var point = new BMap. point (112.931, 28.169); // create Point Coordinate map. centerAndZoom (point, 15); // initialize the map and set the coordinates of the center and map level. enableScrollWheelZoom ();

Display map controls:

// Display map control map. addControl (new BMap. mapTypeControl ({mapTypes: [BMAP_NORMAL_MAP, BMAP_HYBRID_MAP]}); // 2D map, satellite map. addControl (new BMap. mapTypeControl ({anchor: BMAP_ANCHOR_TOP_RIGHT}); // in the upper left corner, the default map control is map. setCurrentCity ("Changsha"); // you need to set the city because of the 3D image. // Add the zoom control map. addControl (new BMap. navigationControl (); // Add the default zoom and Pan control // Add the map of the scale control. addControl (new BMap. scaleControl ({anchor: BMAP_ANCHOR_BOTTOM_LEFT}); // lower left

Related Article

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: info-contact@alibabacloud.com 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.