You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

plot.html 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=device-width,initial-scale=1.0" />
  6. <title>dc-example</title>
  7. <script src="/libs/dc-sdk/dc.min.js"></script>
  8. <link href="/libs/dc-sdk/dc.min.css" type="text/css" rel="stylesheet" />
  9. <link href="../index.css" type="text/css" rel="stylesheet" />
  10. </head>
  11. <body>
  12. <div id="viewer-container" class="viewer-container"></div>
  13. <div class="btn-box">
  14. <ul>
  15. <li><button onclick="draw('point')">点</button></li>
  16. <li><button onclick="draw('billboard')">图标点</button></li>
  17. <li><button onclick="draw('polyline')">线</button></li>
  18. <li><button onclick="draw('polygon')">面</button></li>
  19. <li><button onclick="draw('circle')">圆</button></li>
  20. <li><button onclick="draw('rect')">矩形</button></li>
  21. <li><button onclick="draw('attack_arrow')">进攻箭头</button></li>
  22. <li><button onclick="draw('double_arrow')">双箭头</button></li>
  23. <li><button onclick="draw('fine_arrow')">直箭头</button></li>
  24. <li><button onclick="draw('tailed_attack_arrow')">燕尾箭头</button></li>
  25. <li><button onclick="draw('gathering_place')">聚集地</button></li>
  26. <li><button onclick="draw('bezier_curve')">曲线</button></li>
  27. <li><button onclick="removeAll()">清除</button></li>
  28. </ul>
  29. </div>
  30. <script>
  31. DC.config.baseUrl = '../libs/dc-sdk/resources/'
  32. let viewer = new DC.Viewer('viewer-container')
  33. let baseLayer = DC.ImageryLayerFactory.createImageryLayer(
  34. DC.ImageryType.AMAP,
  35. {
  36. style: 'img',
  37. crs: 'WGS84',
  38. }
  39. )
  40. viewer.addBaseLayer(baseLayer)
  41. let layer = new DC.VectorLayer('layer')
  42. viewer.addLayer(layer)
  43. let plot = new DC.Plot(viewer)
  44. function draw(type) {
  45. plot &&
  46. plot.draw(type, (overlay) => {
  47. if (overlay) {
  48. layer.addOverlay(overlay)
  49. plot.edit(overlay)
  50. }
  51. })
  52. }
  53. function removeAll() {
  54. layer.clear()
  55. }
  56. </script>
  57. </body>
  58. </html>