PolylineOptions 对象规范

折线覆盖物参数。

属性

名称 类型 说明
clickable Boolean 折线是否可点击。
cursor String 鼠标在折线上的光标样式。
editable Boolean 可选项:
true - 启动编辑功能,
false - 默认,不启动编辑功能,
启动编辑功能后,可拖动端点对折线进行调整,双击节点可删除。
map Map 要显示折线的地图。
path Array.<LatLng> | MVCArray.<LatLng> 折线的路径,以经纬度坐标数组构成。
strokeColor Color | String

折线的线条颜色,可通过Color对象的alpha属性设置透明度。

strokeDashStyle String 折线的形状。实线是solid,虚线是dash。
strokeWeight Number 折线的线宽。
strokeLinecap String 折线末端线帽的样式,圆形为round(默认),方形为square,平直为butt。
visible Boolean 折线是否可见。
zIndex Number 折线的zIndex值。

实例

本示例中,介绍了如何使用折线覆盖物的参数

JavaScript
  1. var init = function() {
  2. var center = new qq.maps.LatLng(39.916527, 116.397128);
  3. var map = new qq.maps.Map(document.getElementById('container'), {
  4. center: center,
  5. zoom: 13
  6. });
  7. var path = [
  8. new qq.maps.LatLng(39.910, 116.399),
  9. new qq.maps.LatLng(39.920, 116.405),
  10. new qq.maps.LatLng(39.930, 116.420)
  11. ];
  12.  
  13. var polyline = new qq.maps.Polyline({
  14. //折线是否可点击
  15. clickable: true,
  16. //鼠标在折线上时的样式
  17. cursor: 'crosshair',
  18. //折线是否可编辑
  19. editable: true,
  20. map: map,
  21. //折线的路径
  22. path: path,
  23. //折线的颜色
  24. strokeColor: '#000000',
  25. //可以设置折线的透明度
  26. //strokeColor: new qq.maps.Color(0, 0, 0, 0.5),
  27. //折线的样式
  28. strokeDashStyle: 'dash',
  29. //折线的宽度
  30. strokeWeight: 3,
  31. //折线末端线帽的样式
  32. strokeLinecap: 'square',
  33. //折线是否可见
  34. visible: true,
  35. //折线的zIndex
  36. zIndex: 1000
  37.  
  38.  
  39. });
  40.  
  41. };
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. #info {
  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. <script>
  31. var init = function() {
  32. var center = new qq.maps.LatLng(39.916527, 116.397128);
  33. var map = new qq.maps.Map(document.getElementById('container'), {
  34. center: center,
  35. zoom: 13
  36. });
  37. var path = [
  38. new qq.maps.LatLng(39.910, 116.399),
  39. new qq.maps.LatLng(39.920, 116.405),
  40. new qq.maps.LatLng(39.930, 116.420)
  41. ];
  42.  
  43. var polyline = new qq.maps.Polyline({
  44. //折线是否可点击
  45. clickable: true,
  46. //鼠标在折线上时的样式
  47. cursor: 'crosshair',
  48. //折线是否可编辑
  49. editable: true,
  50. map: map,
  51. //折线的路径
  52. path: path,
  53. //折线的颜色
  54. strokeColor: '#000000',
  55. //可以设置折线的透明度
  56. //strokeColor: new qq.maps.Color(0, 0, 0, 0.5),
  57. //折线的样式
  58. strokeDashStyle: 'dash',
  59. //折线的宽度
  60. strokeWeight: 3,
  61. //折线末端线帽的样式
  62. strokeLinecap: 'square',
  63. //折线是否可见
  64. visible: true,
  65. //折线的zIndex
  66. zIndex: 1000
  67.  
  68.  
  69. });
  70.  
  71. };
  72. </script>
  73. </head>
  74.  
  75. <body onload="init()">
  76. <div style="width:603px;height:300px" id="container"></div>
  77.  
  78. </body>
  79.  
  80. </html>