IE8. 함수 .BIND () 方法
<script type = "text/javaScript"> if (! function.prototype.bind) {function.prototyp.bind = function (othis) {if (type this! == "function") {새 typeError ( "function.prototyp.bind- 부드러운 것은 호출 할 수 없다"); } var aargs = array.prototype.slice.call (Arguments, 1), ftobind = this, fnop = function () {}, fbound = function () {return ftobind.apply (이 인스턴스 fnop && othis? this : othis, aargs.concat (array.concat)))))) }; fnop.prototype = this.prototype; fbound.prototype = new fnop (); 반환 fbound; }; } </스크립트>主要解决“官网上的例子的”百度地图 버그, 摘取如下代码 :
<! 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" /> <text /css "> html {100 : 100 :; 100%; 마진 : 0; Font-Family : "微软雅黑";} #allmap {너비 : 100%; 높이 : 500px;} p {마진-왼쪽 : 5px; font-size : 14px;} </style> <script type = "text/javaScript"src = "http://api.map.baidu.com/api?v=2.0&ak=39b92e64ae5626263ceceaccd8ab8eb1"> <script> <cript src = "http://libs.baidu.com/jquery/1.9.0/jquery.js"> </script> <title> </title> <script type = "text/javaScript"> if (! function.bind.bind) {function.prototype.bind = function (ortis) {if thist (function! TypeError ( "function.prototype.bind- 묶으려고하는 것은 호출 할 수 없습니다"); } var aargs = array.prototype.slice.call (Arguments, 1), ftobind = this, fnop = function () {}, fbound = function () {return ftobind.apply (이 인스턴스 fnop && othis? this : othis, aargs.concat (array.concat)))))) }; fnop.prototype = this.prototype; fbound.prototype = new fnop (); 반환 fbound; }; }. Map.Centerandzoom (New Bmap.point (116.417854,39.921988), 15); var data_info = [[116.417854,39.921988, "地址 : 北京市东城区王府井大街 88 号乐天银泰百货八层", [116.406605,39.921585, "地址 : : 北京市东城区东华门大街"], [116.4122222222222222222222222222222222222222222222222222222222222222222,39.912345, "北京市东城区正义路甲 : :"]; var opts = {너비 : 250, // 信息窗口宽度 높이 : 80, // 信息窗口高度 제목 : "信息窗口", // inablemessage : true // 设置允许信息窗发送短息}; for (var i = 0; i <data_info.length; i ++) {var Marker = new bmap.marker (new bmap.point (data_info [i] [0], data_info [i] [1])); // 创建标注 var content = data_info [i] [2]; map.addoverlay (마커); // 将标注添加到地图中 Marker.addeventListener ( "클릭", OpenInfo.bind (null, content)); } 함수 OpenInfo (content, e) {var p = e.target; var point = new bmap.point (p.getPosition (). lng, p.getPosition (). lat); var infowindow = new bmap.infowindow (컨텐츠, opts); // 创建信息窗口对象 map.openinfowindow (Infowindow, Point); // 开启信息窗口} </script>