(function() { setTimeout(() => { if(!(location.href.indexOf("/contact.html") > -1)) { return; } let s = document.createElement("script"); s.src = "https://webapi.amap.com/maps?v=1.4.15&key=58a7fdd9749b485055b47d8c70f88670"; s.type = "text/javascript"; document.head.appendChild(s); s.onload = function() { var map = new AMap.Map("mapContainer",{ resizeEnable: true, //浜岀淮鍦板浘鏄剧ず瑙嗗彛 view: new AMap.View2D({ //鍦板浘涓績鐐 center:new AMap.LngLat(113.565655,34.8185), //鍦板浘鏄剧ず鐨勭缉鏀剧骇鍒 zoom:12 }) }); map.setLang('cn'); //鍦板浘涓坊鍔犲湴鍥炬搷浣淭oolBar鎻掍欢 map.plugin(["AMap.ToolBar"], function(){ var toolBar = new AMap.ToolBar(); map.addControl(toolBar); }); //鍦板浘鍒濆鍖栨椂锛屽湪鍦板浘涓婃坊鍔犱竴涓猰arker鏍囪,榧犳爣鐐瑰嚮marker鍙脊鍑鸿嚜瀹氫箟鐨勪俊鎭獥浣 addMarker(); //娣诲姞marker鏍囪 function addMarker(){ map.clearMap(); var marker = new AMap.Marker({ map: map, //浣嶇疆 position: new AMap.LngLat(113.565655,34.8185), //澶嶆潅鍥炬爣 icon: "http://webapi.amap.com/images/0.png" }); //榧犳爣鐐瑰嚮marker寮瑰嚭鑷畾涔夌殑淇℃伅绐椾綋 AMap.event.addListener(marker,'click',function(){ infoWindow.open(map,marker.getPosition()); }); } //瀹炰緥鍖栦俊鎭獥浣 var infoWindow = new AMap.InfoWindow({ isCustom:true, //浣跨敤鑷畾涔夌獥浣 content:createInfoWindow('娌冲崡瑾夊噷鐢靛瓙绉戞妧鏈夐檺鍏徃',"鍦板潃: 閮戝窞楂樻柊鎶€鏈骇涓氬紑鍙戝尯鎬婚儴浼佷笟鍩哄湴102骞?), offset:new AMap.Pixel(16, -45)//-113, -140 }); //鏋勫缓鑷畾涔変俊鎭獥浣 function createInfoWindow(title,content){ var info = document.createElement("div"); info.className = "info"; // 瀹氫箟椤堕儴鏍囬 var top = document.createElement("div"); var titleD = document.createElement("div"); var closeX = document.createElement("img"); top.className = "info-top"; titleD.innerHTML = title; closeX.src = "http://webapi.amap.com/images/close2.gif"; closeX.onclick = closeInfoWindow; top.appendChild(titleD); top.appendChild(closeX); info.appendChild(top); // 瀹氫箟涓儴鍐呭 var middle = document.createElement("div"); middle.className = "info-middle"; middle.style.backgroundColor='white'; middle.innerHTML = content; info.appendChild(middle); // 瀹氫箟搴曢儴鍐呭 var bottom = document.createElement("div"); bottom.className = "info-bottom"; bottom.style.position = 'relative'; bottom.style.top = '0px'; bottom.style.margin = '0 auto'; var sharp = document.createElement("img"); sharp.src = "http://webapi.amap.com/images/sharp.png"; bottom.appendChild(sharp); info.appendChild(bottom); return info; } //鍏抽棴淇℃伅绐椾綋 function closeInfoWindow(){ map.clearInfoWindow(); } } }, 500); })();