当前位置:   article > 正文

迁徙图_openlayers6结合echarts4实现迁徙图

openlayers迁徙图

28790ca742dfaed069faa67b3286c2cd.png

效果图如下:

c570ecb52f7855997fbbcd1a4c320e31.png


参考GitHub来实现的,更详细的源码以及参数说明见:

sakitam-fdd/ol3Echarts​github.com
0d743c98df6fe482c85112f3b9f90554.png

本篇文章的html源码

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>openlayers6结合echarts4实现迁徙图</title>
  5. <link rel="stylesheet" href="lib/ol.css">
  6. <script src="lib/ol.js"></script>
  7. <script src="lib/echarts.js"></script>
  8. <script src="lib/ol-echarts.js"></script>
  9. <!--<script src="https://cdn.jsdelivr.net/npm/echarts/dist/echarts.js"></script>
  10. <script src="https://unpkg.com/ol-echarts/dist/ol-echarts.js"></script>-->
  11. <style>
  12. html, body, #map {
  13. height: 100%;
  14. margin: 0;
  15. padding: 0;
  16. }
  17. </style>
  18. </head>
  19. <body>
  20. <div id="map"></div>
  21. <script>
  22. /**
  23. * 地图创建初始化
  24. */
  25. var map = new ol.Map({
  26. target: 'map',
  27. layers: [
  28. new ol.layer.Tile({
  29. source: new ol.source.XYZ({
  30. url: 'http://cache1.arcgisonline.cn/arcgis/rest/services/ChinaOnline' +
  31. 'StreetPurplishBlue/MapServer/tile/{z}/{y}/{x}'
  32. })
  33. })
  34. ],
  35. view: new ol.View({
  36. center: [116.55406673632812, 39.94828066015626],
  37. projection: 'EPSG:4326',
  38. zoom: 10
  39. })
  40. });
  41. //迁徙图图层初始化
  42. var echartslayer = new EChartsLayer(getOption());
  43. echartslayer.appendTo(map)
  44. function getOption () {
  45. var geoCoordMap = {
  46. '上海': [121.4648, 31.2891],
  47. '东莞': [113.8953, 22.901],
  48. '东营': [118.7073, 37.5513],
  49. '中山': [113.4229, 22.478],
  50. '临汾': [111.4783, 36.1615],
  51. '临沂': [118.311
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/728175
推荐阅读
相关标签
  

闽ICP备14008679号