Ie8 支持 function.bind () 方法
<script type = "text / javascript"> if (! function.prototype.bind) {function.prototype.bind = function (othis) {if (typeof this! == "function") {throw new typeError ("function.prototype.bind - ce qui essaie d'être lié n'est pas appelée"); } var aargs = array.prototype.slice.call (arguments, 1), ftobind = this, fnop = function () {}, fbound = function () {return ftobind.apply (this instance fnop && othis? this: othis, aargs.concat (array.pototype.slice.call (arruments)); }; fnop.prototype = this.prototype; fbound.prototype = new fnop (); retour fbound; }; } </ script>主要解决 «百度地图» 官网上的例子的 bug , : :
<! Doctype html> <html> <éadf> <meta http-equiv = "contenu-type" contenu = "text / html; charset = utf-8" /> <meta name = "Viewport" contenu = "initial-scale = 1.0, user-scalable = no" /> <style type = "text / css"> body, html {width: 00%; 100%; marge: 0; Font-Family: "微软雅黑";} #allmap {largeur: 100%; hauteur: 500px;} p {margin-left: 5px; Font-Size: 14px;} </ style> <script type = "text / javascript" src = "http://api.map.baidu.com/api?v=2.0&ak=39b92e64ae56226663cececd8ab8eb1"> </cript> <script src = "http://libs.baidu.com/jquery/1.9.0/jquery.js"> </ script> <itle> 给多个点添加信息窗口 </ title> <script type = "text / javascrip TypeError ("function.prototype.bind - Ce qui essaie d'être lié n'est pas appelable"); } var aargs = array.prototype.slice.call (arguments, 1), ftobind = this, fnop = function () {}, fbound = function () {return ftobind.apply (this instance fnop && othis? this: othis, aargs.concat (array.pototype.slice.call (arruments)); }; fnop.prototype = this.prototype; fbound.prototype = new fnop (); retour fbound; }; } </ script> </ head> <body> <div id = "allmap"> </ div> <p> 点击标注点 , 可查看由纯文本构成的简单型信息窗口 </p> </gody> </html> <script type = "text / javascript"> // 百度地图 api 功能 map = new bmap.map ("allmap"); map.CenterandZoom (nouveau BMAP.Point (116.417854,39.921988), 15); var data_info = [[116.417854,39.921988, "地址 : 北京市东城区王府井大街 88 号乐天银泰百货八层"], [116.406605,39.921585, "地址: 北京市东城区东华门大街"], [116.4122222,39.912345, "地址 : : 北京市东城区正义路甲 北京市东城区正义路甲 号 号"]; var opts = {width: 250, // 信息窗口宽度 hauteur: 80, // 信息窗口高度 Titre: "信息窗口", // 信息窗口标题 enableMessage: true // 设置允许信息窗发送短息}; for (var i = 0; i <data_info.length; i ++) {var marqueur = new Bmap.marker (new BMap.point (data_info [i] [0], data_info [i] [1])); // 创建标注 var contenu = data_info [i] [2]; map.AdDoverlay (marqueur); // 将标注添加到地图中 Marker.AdDeventListener ("Click", openInfo.bind (null, contenu)); } fonction openInfo (contenu, e) {var p = e.target; var Point = new Bmap.point (p.getPosition (). lng, p.getPosition (). Lat); var infowindow = new BMAP.infowIndow (contenu, opts); // 创建信息窗口对象 Map.OpenInFowIndow (Infowindow, point); // 开启信息窗口} </ script>