官方地址

http://lbsyun.baidu.com/index.php?title=jspopular

示例地址

http://developer.baidu.com/map/jsdemo.htm#c1_2

坐标搜索识别

http://api.map.baidu.com/lbsapi/getpoint/index.html

我的deme

<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <style type="text/css">
    body,
    html,
    #allmap {
        width: 100%;
        height: 100%;
        overflow: hidden;
        margin: 0;
        font-family: "微软雅黑";
    }
    </style>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=wScbqRzRMx2ppMWkX7IVZQ4HIvNynxdL"></script>
    <script type="text/javascript" src="http://api.map.baidu.com/library/AreaRestriction/1.2/src/AreaRestriction_min.js"></script>
    <title>地图展示</title>
</head>

<body>
    <div id="allmap"></div>
</body>

</html>
<script type="text/javascript">

// 创建Map实例
var map = new BMap.Map("allmap");    

// 地图坐标
var point = new BMap.Point(113.893747,22.949707);

// 初始化地图,设置中心点坐标和地图级别
map.centerAndZoom(point,19);  

 //开启鼠标滚轮缩放
map.enableScrollWheelZoom(true);   

//右上角地图类型控件
map.addControl(new BMap.MapTypeControl());      

//将地图显示范围设定在指定区域,地图拖出该区域后会重新弹回。
var b = new BMap.Bounds(new BMap.Point(113.893747,22.949707),new BMap.Point(113.893747,22.949707));
try {
    BMapLib.AreaRestriction.setBounds(map, b);
} catch (e) {
    console.log(e);
}

 // 创建标注
var point = new BMap.Point(113.893747,22.949707);
var marker = new BMap.Marker(point);
map.addOverlay(marker);               // 将标注添加到地图中
marker.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画

// 复杂的自定义覆盖物
function ComplexCustomOverlay(point, text, mouseoverText){
  this._point = point;
  this._text = text;
  this._overText = mouseoverText;
}
ComplexCustomOverlay.prototype = new BMap.Overlay();
ComplexCustomOverlay.prototype.initialize = function(map){
  this._map = map;
  var div = this._div = document.createElement("div");
  div.style.position = "absolute";
  div.style.zIndex = BMap.Overlay.getZIndex(this._point.lat);
  div.style.backgroundColor = "#EE5D5B";
  div.style.border = "1px solid #BC3B3A";
  div.style.color = "white";
  div.style.height = "18px";
  div.style.padding = "2px";
  div.style.lineHeight = "18px";
  div.style.whiteSpace = "nowrap";
  div.style.MozUserSelect = "none";
  div.style.fontSize = "12px"
  var span = this._span = document.createElement("span");
  div.appendChild(span);
  span.appendChild(document.createTextNode(this._text));
  var that = this;

  var arrow = this._arrow = document.createElement("div");
  arrow.style.background = "url(http://map.baidu.com/fwmap/upload/r/map/fwmap/static/house/images/label.png) no-repeat";
  arrow.style.position = "absolute";
  arrow.style.width = "11px";
  arrow.style.height = "10px";
  arrow.style.top = "22px";
  arrow.style.left = "10px";
  arrow.style.overflow = "hidden";
  div.appendChild(arrow);

  div.onmouseover = function(){
    this.style.backgroundColor = "#6BADCA";
    this.style.borderColor = "#0000ff";
    this.getElementsByTagName("span")[0].innerHTML = that._overText;
    arrow.style.backgroundPosition = "0px -20px";
  }

  div.onmouseout = function(){
    this.style.backgroundColor = "#EE5D5B";
    this.style.borderColor = "#BC3B3A";
    this.getElementsByTagName("span")[0].innerHTML = that._text;
    arrow.style.backgroundPosition = "0px 0px";
  }

  map.getPanes().labelPane.appendChild(div);

  return div;
}

ComplexCustomOverlay.prototype.draw = function(){
  var map = this._map;
  var pixel = map.pointToOverlayPixel(this._point);
  this._div.style.left = pixel.x - parseInt(this._arrow.style.left) + "px";
  this._div.style.top  = pixel.y - 30 + "px";
}

var myCompOverlay = new ComplexCustomOverlay(new BMap.Point(113.893860,22.949800), "我们在这里等你哦","微餐时代信息科技有限公司");

map.addOverlay(myCompOverlay);

</script>

javascript 百度地图的更多相关文章

  1. javascript百度地图使用(根据地名定位、根据经纬度定位)

    需要购买阿里云产品和服务的,点击此链接领取优惠券红包,优惠购买哦,领取后一个月内有效: https://promotion.aliyun.com/ntms/yunparter/invite.html? ...

  2. javascript百度地图添加一个普通标注点(2014-3-8 记)

    1.导入jquery.js文件:<script type="text/javascript" src="js/jquery.js"></scr ...

  3. javascript 百度地图无秘钥(appkey)创建marker标记地图

    创建简单的marker地图不一定需要去百度地图申请key,简单代码实现marker地图,效果如图: html代码如下,代码中的baidu.api.js参考后面的隐藏代码: <!DOCTYPE h ...

  4. (JavaScript) 百度地图与腾讯地图坐标转换

    /** * 坐标转换,百度地图坐标转换成腾讯地图坐标 * lng 腾讯经度(pointy) * lat 腾讯纬度(pointx) * 经度>纬度 */ function bMapToQQMap( ...

  5. javascript 百度地图API - demo

    <!DOCTYPE html> <html> <head> <meta name="viewport" content="ini ...

  6. 最全面的百度地图JavaScript离线版开发

    转载请注明出处:http://www.cnblogs.com/Joanna-Yan/p/5822231.html 项目要求web版百度地图要离线开发.这里总结下自己的开发过程和经验. 大概需求是:每辆 ...

  7. 百度地图JavaScript API覆盖物旋转时出现偏移

    在项目中,调用百度地图JavaScript API,做覆盖物的旋转再添加到地图上,结果出现偏移了. 调试过程中的效果图: 发现图片的旋转并不是按车子的中心来的,而是之外的一个点.最后发现犯了一个很细节 ...

  8. 百度地图JavaScript API本地搜索的结果面板

    <html> <head> <meta http-equiv="Content-Type" content="text/html; char ...

  9. 使用百度地图JavaScript实现驾车/公交/步行导航功能

    <html> <head> <meta http-equiv="Content-Type" content="text/html; char ...

随机推荐

  1. 解决mysql shell执行中文表名报command not found错误

    mysql -h 192.168.22.201 -uusername -ppassword --default-character-set=utf8 rom3 -e "DELETE FROM ...

  2. cdh环境下,spark streaming与flume的集成问题总结

    文章发自:http://www.cnblogs.com/hark0623/p/4170156.html  转发请注明 如何做集成,其实特别简单,网上其实就是教程. http://blog.csdn.n ...

  3. LoadRunner检查点

    web_reg_find("Text=ABC", "SaveCount=abc_count", LAST);51Testing软件测试网V?2Rs.J Gmdw ...

  4. mvc-6依赖管理

    CommonJS CommonJS规范,主要解决命名空间管理模块和用一套标准的编程模式来加载模块: 很快成为了JavaScript模块写法的事实标准: 它包含IO接口,底层的套接字流,以及单元测试等标 ...

  5. ie不支持getElementsByName的解决办法

    在chrome下getElementsByName运行正常,可在IETester7~11下都不支持  w3c规范中getElementsByName是按着name属性进行检索的,而MS的IE却是按着i ...

  6. linux建立ssh信任关系

    一.建立SSH信任将A主机做为客户端(发起SSH请求 ip:192.168.200.170)将B主机作为服务器端(接收ssh请求   ip:192.168.200.149)以上以主动发起SSH登录请求 ...

  7. mysql修改默认编码为UTF8

    Linux下一般是 /etc/my.cnf --在 [mysqld] 标签下加上三行default-character-set = utf8character_set_server = utf8 -- ...

  8. Extjs 属性控件[转载]

    Ext.form.TimeField: 配置项:            maxValue:列表中允许的最大时间            maxText:当时间大于最大值时的错误提示信息          ...

  9. Android自动化测试框架

    1.Monkeyrunner:优点:操作最为简单,可以录制测试脚本,可视化操作:缺点:主要生成坐标的自动化操作,移植性不强,功能最为局限:    2.Rubotium:主要针对某一个APK进行自动化测 ...

  10. ACM spiral grid

    spiral grid 时间限制:2000 ms  |  内存限制:65535 KB 难度:4   描述 Xiaod has recently discovered the grid named &q ...