国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發(fā)設計 > 正文

百度地圖api(摘自百度)

2019-11-17 01:25:09
字體:
來源:轉載
供稿:網友

百度地圖api(摘自百度)

  1 <!DOCTYPE html>  2 <html xmlns="http://www.w3.org/1999/xhtml">  3 <head>  4     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  5     <style type="text/CSS">  6         body, html {  7             width: 100%;  8             height: 100%;  9             overflow: hidden; 10             margin: 0; 11         } 12  13         #allmap { 14             height: 100%; 15             overflow: hidden; 16         } 17     </style> 18     <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=yqYfrk8ClmehOV743RST9c8Z"></script> 19     <script type="text/Javascript" src="http://api.map.baidu.com/library/SearchInfoWindow/1.5/src/SearchInfoWindow_min.js"></script> 20     <link rel="stylesheet"  /> 21  22     <title>SearchInfoWindow</title> 23 </head> 24 <body> 25     <div id="allmap" style="overflow:hidden;zoom:1;position:relative;"> 26         <div id="map" style="height:100%;-webkit-transition: all 0.5s ease-in-out;transition: all 0.5s ease-in-out;"></div> 27     </div> 28     <script type="text/javascript"> 29  30         // 百度地圖API功能 31         var map = new BMap.Map('map'); 32         var poi = new BMap.Point(116.307852, 40.057031); 33         map.centerAndZoom(poi, 16); 34         map.enableScrollWheelZoom(); 35  36         var content = '<div style="margin:0;line-height:20px;padding:2px;">' + 37                         '<img src="/image/logo.png" alt="" style="float:right;zoom:1;overflow:hidden;width:100px;height:100px;margin-left:3px;"/>' + 38                         '地址:北京市海淀區(qū)上地十街10號<br/>電話:(010)59928888<br/>簡介:百度大廈位于北京市海淀區(qū)西二旗地鐵站附近,為百度公司綜合研發(fā)及辦公總部。' + 39                       '</div>'; 40  41         //創(chuàng)建檢索信息窗口對象 42         var searchInfoWindow = null; 43         searchInfoWindow = new BMapLib.SearchInfoWindow(map, content, { 44             title: "百度大廈",      //標題 45             width: 290,             //寬度 46             height: 105,              //高度 47             panel: "panel",         //檢索結果面板 48             enableAutoPan: true,     //自動平移 49             searchTypes: [ 50                 BMAPLIB_TAB_SEARCH,   //周邊檢索 51                 BMAPLIB_TAB_TO_HERE,  //到這里去 52                 BMAPLIB_TAB_FROM_HERE //從這里出發(fā) 53             ] 54         }); 55         var marker = new BMap.Marker(poi); //創(chuàng)建marker對象 56         marker.enableDragging(); //marker可拖拽 57         marker.addEventListener("click", function (e) { 58             searchInfoWindow.open(marker); 59         }) 60         map.addOverlay(marker); //在地圖中添加marker 61         searchInfoWindow.open(marker); //在marker上打開檢索信息串口 62         $("close").onclick = function () { 63             searchInfoWindow.close(); 64         } 65         $("open").onclick = function () { 66             var enableSendToPhone = false; 67             if ($("enableSendToPhone").checked) { 68                 enableSendToPhone = true; 69             } 70             searchInfoWindow = new BMapLib.SearchInfoWindow(map, content, { 71                 title: "百度大廈",      //標題 72                 width: 290,             //寬度 73                 height: 105,              //高度 74                 panel: "panel",         //檢索結果面板 75                 enableAutoPan: true,     //自動平移 76                 enableSendToPhone: enableSendToPhone, //是否啟用發(fā)送到手機 77                 searchTypes: [ 78                     BMAPLIB_TAB_SEARCH,   //周邊檢索 79                     BMAPLIB_TAB_TO_HERE,  //到這里去 80                     BMAPLIB_TAB_FROM_HERE //從這里出發(fā) 81                 ] 82             }); 83             if ($("enableAutoPan").checked) { 84                 searchInfoWindow.enableAutoPan(); 85             } else { 86                 searchInfoWindow.disableAutoPan(); 87             }; 88             searchInfoWindow.open(marker); 89         } 90         $("show").onclick = function () { 91             searchInfoWindow.show(); 92         } 93         $("hide").onclick = function () { 94             searchInfoWindow.hide(); 95         } 96         $("getPosition").onclick = function () { 97             var position = searchInfoWindow.getPosition(); 98             alert("經度:" + position.lng + ";緯度:" + position.lat); 99         }100         $("setValue").onclick = function () {101             searchInfoWindow.setPosition(new BMap.Point($("lng").value, $("lat").value));102             searchInfoWindow.setTitle($("title").value);103             searchInfoWindow.setContent($("content").value);104         }105         $("getContent").onclick = function () {106             alert(searchInfoWindow.getContent());107         }108         $("getTitle").onclick = function () {109             alert(searchInfoWindow.getTitle());110         }111         function $(id) {112             return document.getElementById(id);113         }114 115         //樣式1116         var searchInfoWindow1 = new BMapLib.SearchInfoWindow(map, "信息框1內容", {117             title: "信息框1", //標題118             panel: "panel", //檢索結果面板119             enableAutoPan: true, //自動平移120             searchTypes: [121                 BMAPLIB_TAB_FROM_HERE, //從這里出發(fā)122                 BMAPLIB_TAB_SEARCH   //周邊檢索123             ]124         });125         function openInfoWindow1() {126             searchInfoWindow1.open(new BMap.Point(116.319852, 40.057031));127         }128 129         //樣式2130         var searchInfoWindow2 = new BMapLib.SearchInfoWindow(map, "信息框2內容", {131             title: "信息框2", //標題132             panel: "panel", //檢索結果面板133             enableAutoPan: true, //自動平移134             searchTypes: [135                 BMAPLIB_TAB_SEARCH   //周邊檢索136             ]137         });138         function openInfoWindow2() {139             searchInfoWindow2.open(new BMap.Point(116.324852, 40.057031));140         }141 142         //樣式3143         var searchInfoWindow3 = new BMapLib.SearchInfoWindow(map, "信息框3內容", {144             title: "信息框3", //標題145             width: 290, //寬度146             height: 40, //高度147             panel: "panel", //檢索結果面板148             enableAutoPan: true, //自動平移149             searchTypes: [150             ]151         });152         function openInfoWindow3() {153             searchInfoWindow3.open(new BMap.Point(116.328852, 40.057031));154         }155 156 157         var isPanelShow = false;158         //顯示結果面板動作159         $("showPanelBtn").onclick = function () {160             if (isPanelShow == false) {161                 isPanelShow = true;162                 $("showPanelBtn").style.right = "300px";163                 $("panelWrap").style.width = "300px";164                 $("map").style.marginRight = "300px";165                 $("showPanelBtn").innerHTML = "隱藏檢索結果面板<br/>>";166             } else {167                 isPanelShow = false;168                 $("showPanelBtn").style.right = "0px";169                 $("panelWrap").style.width = "0px";170                 $("map").style.marginRight = "0px";171                 $("showPanelBtn").innerHTML = "顯示檢索結果面板<br/><";172             }173         }174     </script>175 </body>176 </html>

詳細實例請參考百度api


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 滕州市| 吴旗县| 宿迁市| 霍林郭勒市| 桑日县| 九江市| 佛学| 诏安县| 曲水县| 沙湾县| 鸡泽县| 克东县| 兰溪市| 星子县| 桦川县| 青川县| 滁州市| 哈密市| 南江县| 德惠市| 昭觉县| 定西市| 宁乡县| 雅安市| 疏附县| 读书| 东丰县| 龙口市| 太和县| 乐亭县| 北川| 乌鲁木齐市| 灯塔市| 石景山区| 博客| 江油市| 龙里县| 邢台县| 定边县| 莱州市| 平阴县|