百度地圖API使用示例
阿新 • • 發佈:2019-02-15
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <style type="text/css"> body, html{width: 100%;height: 100%; margin:0;font-family:"微軟雅黑";} #l-map{height:300px;width:100%;} #r-result{width:100%;} </style> <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=您的金鑰"></script> <title>本地搜尋的結果面板</title> </head> <body> <div id="l-map"></div> <div id="r-result"></div> </body> </html> <script type="text/javascript"> // 百度地圖API功能 var map = new BMap.Map("l-map"); // 建立Map例項 map.centerAndZoom(new BMap.Point(116.404, 39.915), 11); var local = new BMap.LocalSearch("蘇州", { renderOptions: {map: map, panel: "r-result"} }); local.search("學校"); </script>