百度地图开发demo

<!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?type=webgl&v=2.0&ak=tzRMGsRbNXUyPhOc0eHLDVmt2cOqyDUP"></script> -->
	<script type="text/javascript" src="http://api.map.baidu.com/getscript?v=2.0&amp;ak=tzRMGsRbNXUyPhOc0eHLDVmt2cOqyDUP&amp;services=&amp;t=20200824135534"></script>
	<title>地图展示</title>
</head>
<body>
	<div id="allmap"></div>
</body>
</html>
<script>
   // 百度地图API功能
	var map = new BMap.Map("allmap");
	var point = new BMap.Point(117.144573,36.661081);
	map.centerAndZoom(point,12);
	map.enableScrollWheelZoom(true);
	// 创建地址解析器实例
	var myGeo = new BMap.Geocoder();
	// 将地址解析结果显示在地图上,并调整地图视野
	myGeo.getPoint("济南市海信龙奥", function(point){
		if (point) {
			map.centerAndZoom(point, 16);
			map.addOverlay(new BMap.Marker(point));
		}else{
			alert("您选择地址没有解析到结果!");
		}
    }, "济南市");
   
	var geoc = new BMap.Geocoder();    
	map.addEventListener("click", function(e){        
	    var pt = e.point;
	    geoc.getLocation(pt, function(rs){
	    	console.log(rs);
	        alert(rs.address+"海信龙奥");
	    });
	});

	var opts = {
	  width : 200,     // 信息窗口宽度
	  height: 100,     // 信息窗口高度
	  title : "***智能科技有限公司" , // 信息窗口标题
	  enableMessage:true,//设置允许信息窗发送短息
	  message:"戳下面的链接看下地址喔~"
	}
	var infoWindow = new BMap.InfoWindow("地址:山东省济南市海信龙奥", opts);  // 创建信息窗口对象 
	map.openInfoWindow(infoWindow,point); //开启信息窗口

</script>

vue中使用百度地图:Vue Baidu Map

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

木易66丶

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值