<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>支行地圖查詢 - 農商銀行</title> <style type="text/css"> * { margin: 0; padding: 0; } body { color: #2B2B2B; font: 12px/20px tahoma,宋體,sans-serif; min-width: 1000px; } input { background: none repeat scroll 0 0 #FFFFFF; border: 1px none; color: #666666; } textarea { font-size: 12px; resize: none; } img { border: medium none; } a { color: #2B2B2B; text-decoration: none; } a:hover { text-decoration: underline; } a:focus { outline: thin dotted; } span, em, i, address { font-style: normal; } span, em, i, strong, b, a { display: inline-block; } table { border-collapse: collapse; border-spacing: 0; } li { list-style: none outside none; } .top { width: 100%; height: 100px; position: absolute; top: 0; left: 0; right: 0; } .top img { margin-top: 30px; margin-left: 40px; } .lefttop { width: 300px; position: absolute; left: 0; top: 100px; height: 28px; line-height: 28px; background-image: url(Widgets/Themes/theme/images/mapinfo_4awatk.png); background-position: right -68px; } .lefttop span { padding-left: 15px; } .lefttop b { width: 8px; height: 8px; background-color: #A5BEEF; border-radius: 4px; } .lefttop a { padding-left: 8px; color: #4C73C2; } .righttop { position: absolute; left: 300px; top: 100px; right: 0px; height: 28px; background-image: url(Widgets/Themes/theme/images/nav_bj_24a15l.gif); } .left { width: 300px; position: absolute; left: 0; top: 128px; bottom: 0; border-top: 1px solid #E7E7E7; padding: 10px; } .left .con { background-color: #F7F3F7; min-height: 400px; width: 260px; padding: 10px; } .left .con span { background-image: url(Widgets/Themes/theme/images/markers_new_hdbsij.png); background-repeat: no-repeat; background-position: 0 -71px; width: 24px; height: 40px; float: left; } .left .con p { margin-left: 30px; line-height: 30px; padding-top: 8px; } .right { position: absolute; top: 128px; bottom: 0; left: 300px; right: 0; border-top: 1px solid #E7E7E7; } </style> </head> <body> <div class="top"> <img src="Widgets/Themes/theme/images/logo.png" /> 支行地圖查詢 </div> <div class="lefttop"> <span><b></b><a href="/">首頁</a></span> </div> <div class="righttop"> </div> <div class="left"> <div class="con"> <span></span> <p> <b id="name">農村商業銀行</b><br /> <em id="add">地址:廣東省農商行大廈 </em> <br /> 電話:<em id="tel">020-2858028 2853308</em> <br /> 傳真:<em id="cz">2853308</em> <br /> 日常營業時間:<em id="rc">9:00-17:00</em><br /> 節假日營業時間:<em id="jj">9:30-16:30</em> </p> </div> </div> <div class="right" id="dituContent"> </div> <script type="text/javascript" src="http://api.map.baidu.com/api?key=&v=1.1&services=true"></script> <script type="text/javascript"> function getUrlParam(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //構造一個含有目標引數的正規表示式物件 var r = window.location.search.substr(1).match(reg); //匹配目標引數 if (r != null) return unescape(r[2]); return null; //返回引數值 } var mx = getUrlParam("x"); var my = getUrlParam("y"); var mn = getUrlParam("n"); document.getElementById("name").innerHTML = getUrlParam("n"); document.getElementById("add").innerHTML = "地址:" + getUrlParam("add"); document.getElementById("tel").innerHTML = getUrlParam("tel"); document.getElementById("cz").innerHTML = getUrlParam("tel"); //建立和初始化地圖函式: function initMap() { createMap(); //建立地圖 setMapEvent(); //設定地圖事件 addMapControl(); //向地圖新增控制元件 addMarker(); //向地圖中新增marker } //建立地圖函式: function createMap() { var map = new BMap.Map("dituContent"); //在百度地圖容器中建立一個地圖 var point = new BMap.Point(parseFloat(mx), parseFloat(my)); //定義一箇中心點座標 map.centerAndZoom(point, 15); //設定地圖的中心點和座標並將地圖顯示在地圖容器中 window.map = map; //將map變數儲存在全域性 } //地圖事件設定函式: function setMapEvent() { map.enableDragging(); //啟用地圖拖拽事件,預設啟用(可不寫) map.enableScrollWheelZoom(); //啟用地圖滾輪放大縮小 map.enableDoubleClickZoom(); //啟用滑鼠雙擊放大,預設啟用(可不寫) map.enableKeyboard(); //啟用鍵盤上下左右鍵移動地圖 } //地圖控制元件新增函式: function addMapControl() { //向地圖中新增縮放控制元件 var ctrl_nav = new BMap.NavigationControl({ anchor: BMAP_ANCHOR_TOP_LEFT, type: BMAP_NAVIGATION_CONTROL_LARGE }); map.addControl(ctrl_nav); //向地圖中新增縮圖控制元件 var ctrl_ove = new BMap.OverviewMapControl({ anchor: BMAP_ANCHOR_BOTTOM_RIGHT, isOpen: 1 }); map.addControl(ctrl_ove); //向地圖中新增比例尺控制元件 var ctrl_sca = new BMap.ScaleControl({ anchor: BMAP_ANCHOR_BOTTOM_LEFT }); map.addControl(ctrl_sca); } //標註點陣列 var pointxy = mx + "|" + my; var markerArr = [{ title: mn, content: "", point: pointxy, isOpen: 0, icon: { w: 21, h: 21, l: 0, t: 0, x: 6, lb: 5} } ]; //建立marker function addMarker() { for (var i = 0; i < markerArr.length; i++) { var json = markerArr[i]; var p0 = json.point.split("|")[0]; var p1 = json.point.split("|")[1]; var point = new BMap.Point(p0, p1); var iconImg = createIcon(json.icon); var marker = new BMap.Marker(point, { icon: iconImg }); var iw = createInfoWindow(i); var label = new BMap.Label(json.title, { "offset": new BMap.Size(json.icon.lb - json.icon.x + 10, -20) }); marker.setLabel(label); map.addOverlay(marker); label.setStyle({ borderColor: "#808080", color: "#333", cursor: "pointer" }); (function () { var index = i; var _iw = createInfoWindow(i); var _marker = marker; _marker.addEventListener("click", function () { this.openInfoWindow(_iw); }); _iw.addEventListener("open", function () { _marker.getLabel().hide(); }) _iw.addEventListener("close", function () { _marker.getLabel().show(); }) label.addEventListener("click", function () { _marker.openInfoWindow(_iw); }) if (!!json.isOpen) { label.hide(); _marker.openInfoWindow(_iw); } })() } } //建立InfoWindow function createInfoWindow(i) { var json = markerArr[i]; var iw = new BMap.InfoWindow("<b class='iw_poi_title' title='" + json.title + "'>" + json.title + "</b><div class='iw_poi_content'>" + json.content + "</div>"); return iw; } //建立一個Icon function createIcon(json) { var icon = new BMap.Icon("http://app.baidu.com/map/images/us_mk_icon.png", 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) }) return icon; } initMap(); //建立和初始化地圖 </script> </body> </html>