(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.82837964385749,36.12011833388435), //地图显示的缩放级别 zoom:12 }) }); map.setLang('cn'); //地图中添加地图操作ToolBar插件 map.plugin(["AMap.ToolBar"], function(){ var toolBar = new AMap.ToolBar(); map.addControl(toolBar); }); //地图初始化时,在地图上添加一个marker标记,鼠标点击marker可弹出自定义的信息窗体 addMarker(); //添加marker标记 function addMarker(){ map.clearMap(); var marker = new AMap.Marker({ map: map, //位置 position: new AMap.LngLat(113.82837964385749,36.12011833388435), //复杂图标 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(' BOB体育客户端下载',"地址:中国河南省林州市红旗渠经济技术开发区BOB体育手机APP下载大道西段北侧"), 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); })();