1 2 3 4function baiduMap(markerArr,bMap){ 5 //æ æ³¨ç¹æ°ç» 6 this.markerArr = markerArr; 7 markerArr = [{title:"æçæ è®°",content:"æç夿³¨",point:"114.033159|22.538665",isOpen:1,icon:{w:22,h:22,l:0,t:22,x:6,lb:5}}]; 8 9 //å建ååå§åå°å¾å½æ°ï¼ 10 function initMap(){ 11 createMap();//å建å°å¾ 12 setMapEvent();//设置å°å¾äºä»¶ 13 addMapControl();//åå°å¾æ·»å æ§ä»¶ 14 addMarker();//åå°å¾ä¸æ·»å marker 15 } 16 17 //å建å°å¾å½æ°ï¼ 18 function createMap(){ 19 var map = new BMap.Map(bMap);//å¨ç¾åº¦å°å¾å®¹å¨ä¸å建ä¸ä¸ªå°å¾ 20 var json = this.markerArr[0]; 21 var p0 = parseFloat(json.point.split("|")[0]); 22 var p1 = parseFloat(json.point.split("|")[1]); 23 var point = new BMap.Point(p0,p1);//å®ä¹ä¸ä¸ªä¸å¿ç¹åæ 24 map.centerAndZoom(point,13);//设å®å°å¾çä¸å¿ç¹ååæ å¹¶å°å°å¾æ¾ç¤ºå¨å°å¾å®¹å¨ä¸ 25 window.map = map;//å°mapåéåå¨å¨å ¨å± 26 //ä¿®æ¹å°å¾çæ ·å¼ 27 /* 28 var style_map=[{ 29 featureType: "poi", 30 elementType: "labels", 31 stylers: { 32 visibility: "off" 33 } 34 }, { 35 featureType: "subway", 36 elementType: "all", 37 stylers: { 38 visibility: "off" 39 } 40 }, { 41 featureType: "local", 42 elementType: "all", 43 stylers: { 44 color: "#ffffff", 45 weight: "0.3" 46 } 47 }, { 48 featureType: "green", 49 elementType: "all", 50 stylers: { 51 color: "#e6e6e6" 52 } 53 }, { 54 featureType: "water", 55 elementType: "all", 56 stylers: { 57 color: "#ededed" 58 } 59 }, { 60 featureType: "land", 61 elementType: "all", 62 stylers: { 63 color: "#f7f7f7" 64 } 65 }, { 66 featureType: "manmade", 67 elementType: "all", 68 stylers: { 69 color: "#f7f7f7", 70 visibility: "off" 71 } 72 }, { 73 featureType: "building", 74 elementType: "all", 75 stylers: { 76 color: "#f2f2f2" 77 } 78 }, { 79 featureType: "highway", 80 elementType: "geometry", 81 stylers: { 82 color: "#ffffff", 83 weight: "0.5" 84 } 85 }, { 86 featureType: "arterial", 87 elementType: "all", 88 stylers: { 89 color: "#ffffff", 90 weight: "0.3" 91 } 92 }, { 93 featureType: "railway", 94 elementType: "all", 95 stylers: { 96 visibility: "off" 97 } 98 }, { 99 featureType: "highway", 100 elementType: "labels.text.fill", 101 stylers: { 102 color: "#9f9f9f" 103 } 104 }, { 105 featureType: "arterial", 106 elementType: "labels.text.fill", 107 stylers: { 108 color: "#b4b4b4", 109 weight: "0.1" 110 } 111 }, { 112 featureType: "label", 113 elementType: "labels.text.fill", 114 stylers: { 115 color: "#666666" 116 } 117 }, { 118 featureType: "administrative", 119 elementType: "all", 120 stylers: {} 121 }, { 122 featureType: "local", 123 elementType: "labels.text.fill", 124 stylers: { 125 color: "#dfdfdf" 126 } 127 }, { 128 featureType: "highway", 129 elementType: "labels.text.stroke", 130 stylers: { 131 color: "#ffffff" 132 } 133 }, { 134 featureType: "highway", 135 elementType: "labels.icon", 136 stylers: { 137 visibility: "off" 138 } 139 }, { 140 featureType: "label", 141 elementType: "labels.text.stroke", 142 stylers: { 143 color: "#ffffff" 144 } 145 }, { 146 featureType: "boundary", 147 elementType: "all", 148 stylers: {} 149 }] 150 //å°æ ·å¼å è½½å°å°å¾ä¸ 151 map.setMapStyle({styleJson:eval("style_map")}); 152 */ 153 } 154 155 //å°å¾äºä»¶è®¾ç½®å½æ°ï¼ 156 function setMapEvent(){ 157 map.enableDragging();//å¯ç¨å°å¾ææ½äºä»¶ï¼é»è®¤å¯ç¨(å¯ä¸å) 158 map.enableScrollWheelZoom();//å¯ç¨å°å¾æ»è½®æ¾å¤§ç¼©å° 159 map.enableDoubleClickZoom();//å¯ç¨é¼ æ å廿¾å¤§ï¼é»è®¤å¯ç¨(å¯ä¸å) 160 map.enableKeyboard();//å¯ç¨é®çä¸ä¸å·¦å³é®ç§»å¨å°å¾ 161 } 162 163 //å°å¾æ§ä»¶æ·»å 彿°ï¼ 164 function addMapControl(){ 165 //åå°å¾ä¸æ·»å ç¼©æ¾æ§ä»¶ 166 //var ctrl_nav = new BMap.NavigationControl({anchor:BMAP_ANCHOR_TOP_LEFT,type:BMAP_NAVIGATION_CONTROL_LARGE}); 167 // map.addControl(ctrl_nav); 168 //åå°å¾ä¸æ·»å 缩ç¥å¾æ§ä»¶ 169 //var ctrl_ove = new BMap.OverviewMapControl({anchor:BMAP_ANCHOR_BOTTOM_RIGHT,isOpen:1}); 170 //map.addControl(ctrl_ove); 171 //åå°å¾ä¸æ·»å æ¯ä¾å°ºæ§ä»¶ 172 //var ctrl_sca = new BMap.ScaleControl({anchor:BMAP_ANCHOR_BOTTOM_LEFT}); 173 //map.addControl(ctrl_sca); 174 } 175 176 177 //å建marker 178 function addMarker(){ 179 for(var i=0;i<this.markerArr.length;i++){ 180 var json = this.markerArr[i]; 181 console.log('json') 182 console.log(json) 183 var p0 = Number(json.point.split("|")[0]); 184 var p1 = parseFloat(json.point.split("|")[1]); 185 186 var point = new BMap.Point(p0,p1); 187 console.log(p0) 188 var iconImg = createIcon(json.icon); 189 var marker = new BMap.Marker(point,{icon:iconImg}); 190 191 var iw = createInfoWindow(i); 192 193 194 var label = new BMap.Label(json.title,{"offset":new BMap.Size(json.icon.lb-json.icon.x+10,-1000)}); 195 marker.setLabel(label); 196 //设置markerç¹è·³å¨ 197 // marker.setAnimation(BMAP_ANIMATION_BOUNCE); 198 map.addOverlay(marker); 199 200 201 (function(){ 202 var index = i; 203 var _iw = createInfoWindow(i); 204 var _marker = marker; 205 // var _search=searchInfoWindow(); 206 _marker.addEventListener("click",function(){ 207 this.openInfoWindow(_iw); 208 // _search.open(_marker); 209 }); 210 _iw.addEventListener("open",function(){ 211 _marker.getLabel().hide(); 212 }) 213 _iw.addEventListener("close",function(){ 214 _marker.getLabel().show(); 215 }) 216 label.addEventListener("click",function(){ 217 _marker.openInfoWindow(_iw); 218 }) 219 if(!!json.isOpen){ 220 label.hide(); 221 _marker.openInfoWindow(_iw); 222 //æ·»å æ£ç´¢åè½æ¡ 223 // _search.open(_marker); 224 } 225 })() 226 227 } 228 } 229 //å建InfoWindow 230 function createInfoWindow(i){ 231 var json = this.markerArr[i]; 232 console.log(json) 233 // var iw = new BMap.InfoWindow("<b class='iw_poi_title' title='" + json.title + "'>" + json.title + "</b><div class='iw_poi_content'>"+json.content+"</div>"); 234 235 var infoWindow = new BMap.InfoWindow("<div class='BMap_bubble_content'><div class='close' onclick='closeWindow();'><img src='https://api.map.baidu.com/images/iw_close1d3.gif'></div><div class='iw_poi_title' title='" + json.title + "'>" + json.title + "</div><div class='iw_poi_content'>"+json.content+"</div></div>",{ 236 // title: json.title, //æ é¢ 237 enableAutoPan : true, //èªå¨å¹³ç§» 238 239 width: 320, //宽度 240 height: 150, //é«åº¦ 241 enableMessage:true}); // å建信æ¯çªå£å¯¹è±¡ 242 var lng = parseFloat(json.point.split("|")[0]) 243 244 var lat = parseFloat(json.point.split("|")[1]) 245 map.openInfoWindow(infoWindow, new BMap.Point(lng, lat)); 246 247 248 //map.closeInfoWindow() 249 250 return infoWindow; 251 } 252 //å建ä¸ä¸ªIcon 253 function createIcon(json){ 254 //èªå®ä¹å¾æ 255 //{w:23,h:25,l:46,t:21,x:9,lb:12} 256 257 var icon = new BMap.Icon(IMG+"/map_marker.png", 258 new BMap.Size(100,100),{imageOffset: new BMap.Size(40,12),infoWindowOffset:new BMap.Size(17,1),offset:new BMap.Size(9,40)}); 259 //var icon = new BMap.Icon("http://api.map.baidu.com/lbsapi/creatmap/images/us_cursor.gif", 260 //new BMap.Size(json.w,json.h),{imageOffset: new BMap.Size(-json.l,-json.t),infoWindowOffset:new BMap.Size(json.lb+5,1),offset:new BMap.Size(json.x,json.h)}) 261 return icon; 262 } 263 // 264 265 266 //å建searchinfo 267 function searchInfoWindow(){ 268 var searchInfoWindow = null; 269 var content = '<div style="margin:0;line-height:20px;padding:2px;">' + 270 '<img src="../img/baidu.jpg" alt="" style="float:right;zoom:1;overflow:hidden;width:100px;height:100px;margin-left:3px;"/>' + 271 'å°åï¼åäº¬å¸æµ·æ·åºä¸å°åè¡10å·<br/>çµè¯ï¼(010)59928888<br/>ç®ä»ï¼ç¾åº¦å¤§å¦ä½äºåäº¬å¸æµ·æ·åºè¥¿äºæå°éç«éè¿ï¼ä¸ºç¾åº¦å ¬å¸ç»¼åç åååå ¬æ»é¨ã' + 272 '</div>'; 273 274 searchInfoWindow = new BMapLib.SearchInfoWindow(map, content, { 275 title : "ç¾åº¦å¤§å¦", //æ é¢ 276 width : 290, //宽度 277 height : 105, //é«åº¦ 278 panel : "panel", //æ£ç´¢ç»æé¢æ¿ 279 enableAutoPan : true, //èªå¨å¹³ç§» 280 searchTypes :[ 281 BMAPLIB_TAB_SEARCH, //å¨è¾¹æ£ç´¢ 282 BMAPLIB_TAB_TO_HERE, //å°è¿éå» 283 BMAPLIB_TAB_FROM_HERE //ä»è¿éåºå 284 ] 285 }); 286 return searchInfoWindow; 287 } 288 289 initMap();//å建ååå§åå°å¾ 290} 291 292 function closeWindow(){ 293 map.closeInfoWindow(); 294 295 }
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.