Page insert Baidu Map (using the Baidu Map API)

Source: Internet
Author: User

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvewf5dw4wnte2/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center ">

The. aspx code is as follows:

<%@ page language= "C #" autoeventwireup= "true" codefile= "Insert map. Aspx.cs" inherits= "Insert Map"%>


<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">


<title></title>
<script type= "Text/javascript" src= "Http://api.map.baidu.com/api?

V=2.0&AMP;AK=NORAEOYTCENXSBGQ7PY9QBRL "> </script>


<body>
<form id= "Form1" runat= "Server" >
<div>

<div id= "Div_baidumap" style= "height:600px; width:600px; border:1px solid silver; "></div>
<script type= "Text/javascript" >


var map = new Bmap.map ("Div_baidumap");
Map.centerandzoom (New Bmap.point (116.321565, 39.979607), 11);

0. Control settings
Pan Zoom
Map.addcontrol (New Bmap.navigationcontrol ());
Mouse wheel zoom in and zoom out
Map.enablescrollwheelzoom ();
//...


1. Join Click to listen
Map.addeventlistener ("click", Function (e) {
Alert (e.point.lng + "," + E.point.lat);
//    });


2. Adding a static identity
var _p = new Bmap.point (116.321565, 39.979607);
var _m1 = new Bmap.marker (_p);
Map.addoverlay (_M1);


3. Animation
_m1.setanimation (bmap_animation_bounce);


4. Pop-up form
var _info1 = new Bmap.infowindow ("Imeson headquarters");
_m1.addeventlistener ("MouseOver", function () {This.openinfowindow (_INFO1);});
_m1.addeventlistener ("Mouseout", function () {This.closeinfowindow (_INFO1);});


5. Label Tips
var _opts = {position: _p, Offset:new bmap.size (25,-10)}
var _lab = new Bmap.label ("corporate headquarters", _opts);
Map.addoverlay (_lab);
_lab.setstyle ({color: "Orange", FontSize: "14px", padding: "6px"});


6. Define your own identity
var _icon = new Bmap.icon (".. /app_imgs/logo40.png ", New Bmap.size (40, 40));
var _m2 = new Bmap.marker (_p, {icon: _icon});
Map.addoverlay (_M2);


</script>
</div>


</form>
</body>

Effects such as the following:


Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.

Page insert Baidu Map (using the 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: 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.