javascript 百度地图API,创建小狐狸,让小狐狸说话
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css"> body, html,#allmap {width: 100%;height: 100%;overflow: hidden;hidden;margin:0;} #l-map{height:100%;width:78%;float:left;border-right:2px solid #bcbcbc;} #r-result{height:100%;width:20%;float:left;} </style> <script type="text/javascript" src="http://api.map.baidu.com/api?v=1.3"></script> <title>添加普通标注点</title> </head> <body> <div id="allmap"></div> </body> </html> <script type="text/javascript"> var map = new BMap.Map("allmap"); map.centerAndZoom(new BMap.Point(116.404, 39.915), 14); var marker1 = new BMap.Marker(new BMap.Point(116.384, 39.925)); // 创建标注 map.addOverlay(marker1); // 将标注添加到地图中 //创建信息窗口 var infoWindow1 = new BMap.InfoWindow("普通标注"); marker1.addEventListener("click", function(){this.openInfoWindow(infoWindow1);}); //创建小狐狸 var pt = new BMap.Point(116.417, 39.909); var myIcon = new BMap.Icon("fox.gif", new BMap.Size(300,157)); var marker2 = new BMap.Marker(pt,{icon:myIcon}); // 创建标注 map.addOverlay(marker2); // 将标注添加到地图中 //让小狐狸说话(创建信息窗口) var infoWindow2 = new BMap.InfoWindow("<p style='font-size:14px;'>哈哈,你看见我啦!我可不常出现哦!</p><p style='font-size:14px;'>赶快查看源代码,看看我是如何添加上来的!</p>"); marker2.addEventListener("click", function(){this.openInfoWindow(infoWindow2);}); </script>
相关推荐
etzt 2020-04-16
etzt 2020-01-06
worldkun 2019-12-20
jishume 2011-07-19
xcjing 2015-11-12
XiaoyiXie 2019-04-25
xiaoshe 2014-07-10
蓝色诱惑 2014-07-10
zmosquito 2016-11-21
zmosquito 2015-05-20
nutian 2016-07-04
chang00 2013-05-02
bingxingke 2013-01-28
zmosquito 2013-01-23
semjinghua 2012-12-14
bingxingke 2012-05-17
channeldotren 2018-01-26
qrcwkt 2017-11-06