test.html 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
  5. <script type="text/javascript" src="//api.map.baidu.com/api?type=webgl&v=1.0&ak=pAT8YhkMx1HVQIWOLZcYoQAty1myB4Sn"></script>
  6. <title>根据关键字本地搜索</title>
  7. <style>
  8. body,
  9. html,
  10. #container {
  11. overflow: hidden;
  12. width: 100%;
  13. height: 100%;
  14. margin: 0;
  15. font-family: "微软雅黑";
  16. }
  17. .info {
  18. z-index: 999;
  19. width: auto;
  20. min-width: 22rem;
  21. padding: .75rem 1.25rem;
  22. margin-left: 1.25rem;
  23. position: fixed;
  24. top: 1rem;
  25. background-color: #fff;
  26. border-radius: .25rem;
  27. font-size: 14px;
  28. color: #666;
  29. box-shadow: 0 2px 6px 0 rgba(27, 142, 236, 0.5);
  30. }
  31. </style>
  32. </head>
  33. <body>
  34. <div id="container"></div>
  35. <div class = "info">返回北京市“景点”关键字的检索结果,并展示在地图上</div>
  36. </body>
  37. </html>
  38. <script type="text/javascript">
  39. // 百度地图API功能
  40. var map = new BMapGL.Map('container');
  41. map.centerAndZoom(new BMapGL.Point(116.404, 39.915), 11);
  42. var local = new BMapGL.LocalSearch(map, {
  43. renderOptions: {map: map}
  44. });
  45. local.search('郑州');
  46. </script>