PanControlOptions 对象规范

平移控件参数。

属性

名称 类型 说明
position ControlPosition 设置控件位置。

实例

本示例中,介绍如何设置平移控件位置

JavaScript
  1. var init = function() {
  2. var map = new qq.maps.Map(document.getElementById("container"), {
  3. center: new qq.maps.LatLng(39.916527, 116.397128),
  4. zoom: 13,
  5. //启用平移控件
  6. panControl: true,
  7. //设置平移控件的位置
  8. panControlOptions: {
  9. //设置平移控件的位置为相对右方中间位置对齐.
  10. position: qq.maps.ControlPosition.RIGHT_CENTER
  11.  
  12. }
  13.  
  14. });
  15.  
  16. }
JavaScript+HTML
  1. <!DOCTYPE html>
  2. <html>
  3.  
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
  7. <title>设置平移控件位置</title>
  8. <style type="text/css">
  9. * {
  10. margin: 0px;
  11. padding: 0px;
  12. }
  13. body,
  14. button,
  15. input,
  16. select,
  17. textarea {
  18. font: 12px/16px Verdana, Helvetica, Arial, sans-serif;
  19. }
  20. p {
  21. width: 603px;
  22. padding-top: 3px;
  23. overflow: hidden;
  24. }
  25. .btn {
  26. width: 142px;
  27. }
  28. </style>
  29. <script charset="utf-8" src="https://map.qq.com/api/js?v=2.exp&key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77"></script>
  30.  
  31. </head>
  32.  
  33. <body onload="init()">
  34. <script>
  35. var init = function() {
  36. var map = new qq.maps.Map(document.getElementById("container"), {
  37. center: new qq.maps.LatLng(39.916527, 116.397128),
  38. zoom: 13,
  39. //启用平移控件
  40. panControl: true,
  41. //设置平移控件的位置
  42. panControlOptions: {
  43. //设置平移控件的位置为相对右方中间位置对齐.
  44. position: qq.maps.ControlPosition.RIGHT_CENTER
  45.  
  46. }
  47.  
  48. });
  49.  
  50. }
  51. </script>
  52. <div style="width:603px;height:300px" id="container"></div>
  53.  
  54. </body>
  55.  
  56. </html>