Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

路线图放大后会导致路线开始位置发生变化 #27

Open
wb-wenbei opened this issue Jul 13, 2021 · 8 comments
Open

路线图放大后会导致路线开始位置发生变化 #27

wb-wenbei opened this issue Jul 13, 2021 · 8 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@wb-wenbei
Copy link

image
正常显示应该是这样
image
放大到一定程度后会出现下方的线都显示到上方去了,感觉像是起点位置变了

@wb-wenbei
Copy link
Author

插件版本:
"echarts": "^4.6.0",
"echarts-extension-amap": "^1.9.3",

@plainheart
Copy link
Owner

能给个简单点的示例么

@BraisedChicken
Copy link

codesandbox是需要高德key的,所以例子不是很方便。我也有同样的问题,利用echarts绘制飞线效果,当缩放较深,部分视口内的点生成的飞线位置就会错乱。

@BraisedChicken
Copy link

Screen Shot 2021-07-23 at 11 15 58 AM
Screen Shot 2021-07-23 at 11 16 08 AM
Screen Shot 2021-07-23 at 11 16 22 AM
可以看到,同样的坐标,放大到一定层级后,很多飞线跑到上方去了,正常缩放下都处于目标点下方

@plainheart
Copy link
Owner

可以提供下例子,不用写 key。

@plainheart plainheart added the question Further information is requested label Jan 9, 2022
@wb-wenbei
Copy link
Author

wb-wenbei commented Jan 11, 2022

1641883408(1)

测试浏览器:谷歌浏览器(版本 97.0.4692.71(正式版本) (64 位))
1641883846(1)

示例:
https://gist.github.com/wenbei111/30ee11b23888123b4f2f2cd3863093d6

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="renderer" content="webkit">
  <meta http-equiv="cleartype" content="on">
  <meta http-equiv="x-dns-prefetch-control" content="on">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <link rel="dns-prefetch" href="https://cdn.jsdelivr.net">
  <link rel="dns-prefetch" href="https://webapi.amap.com">
  <link rel="dns-prefetch" href="https://restapi.amap.com">
  <link rel="dns-prefetch" href="https://vdata.amap.com">
  <link rel="dns-prefetch" href="https://vdata01.amap.com">
  <link rel="dns-prefetch" href="https://vdata02.amap.com">
  <link rel="dns-prefetch" href="https://vdata03.amap.com">
  <link rel="dns-prefetch" href="https://vdata04.amap.com">
  <link rel="dns-prefetch" href="https://sdf.amap.com">
  <link rel="dns-prefetch" href="https://wprd01.is.autonavi.com">
  <link rel="dns-prefetch" href="https://wprd02.is.autonavi.com">
  <link rel="dns-prefetch" href="https://wprd03.is.autonavi.com">
  <link rel="dns-prefetch" href="https://wprd04.is.autonavi.com">
  <link rel="dns-prefetch" href="https://webst01.is.autonavi.com">
  <link rel="dns-prefetch" href="https://webst02.is.autonavi.com">
  <link rel="dns-prefetch" href="https://webst03.is.autonavi.com">
  <link rel="dns-prefetch" href="https://webst04.is.autonavi.com">
  <title>an example for echarts-extension-amap</title>
  <!-- please replace {ak} with your ak & customize your plugins -->
  <!-- Plugin `AMap.CustomLayer` is required if you are using a version of library less than v1.9.0 -->
  <script type="text/javascript" src="https://webapi.amap.com/maps?v=2.0&key={key}&plugin=AMap.Scale,AMap.ToolBar"></script>
  <!-- ECharts CDN -->
  <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts@5/dist/echarts.min.js"></script>
  <!-- echarts amap extension -->
  <!-- <script type="text/javascript" src="../dist/echarts-extension-amap.min.js"></script> -->
  <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected]/dist/echarts-extension-amap.min.js"></script>
  <style type="text/css">
    * {
      margin: 0;
      padding: 0;
    }
    html, body, #echarts-amap {
      width: 100%;
      height: 100%;
      overflow: hidden;
    }
  </style>
</head>
<body>
  <div id="echarts-amap"></div>
  <!-- data comes from Baidu Map, just for example -->
  <script type="text/javascript">
    var option = getOptions()
    // initialize echart
    var chart = echarts.init(document.getElementById('echarts-amap'));
    chart.setOption(option);
    // get AMap extension component
    var amapComponent = chart.getModel().getComponent('amap');
    // get the instance of AMap
    var amap = amapComponent.getAMap();
    // operations below are the same as amap
    amap.addControl(new AMap.Scale());
    amap.addControl(new AMap.ToolBar());
    // add layers
    // var satelliteLayer = new AMap.TileLayer.Satellite();
    // var roadNetLayer = new AMap.TileLayer.RoadNet();
    // amap.add([satelliteLayer, roadNetLayer]);
    // Add a marker to map
    // amap.add(new AMap.Marker({
    //   position: [115, 35]
    // }));
    // Make the overlay layer of AMap interactive
    // amapComponent.setEChartsLayerInteractive(false);

    function getOptions() {
      let p = [[119.823825, 35.771387], [119.833825, 35.771387], [119.843825, 35.771387]]
      let toP = [[119.823825, 35.781387], [119.833825, 35.781387], [119.843825, 35.781387]]
      let l = [
        [[119.823825, 35.771387], [119.823825, 35.781387]],
        [[119.833825, 35.771387], [119.823825, 35.781387]],
        [[119.833825, 35.771387], [119.833825, 35.781387]],
        [[119.833825, 35.771387], [119.843825, 35.781387]],
        [[119.823825, 35.781387], [119.843825, 35.781387]]
      ]
      let options = {
        points: [], toPoints: [], lines: [],
        center: [119.823825, 35.771387]
      }

      p.forEach((item, index) => {
        options.points.push({
          name: "point_" + index,
          value: item,
          symbolSize: 5,
          itemStyle: {
            normal: {
              color: "#74D4FF"
            }
          }
        })
      })

      toP.forEach((item, index) => {
        options.toPoints.push({
          name: "to_point_" + index,
          value: item,
          symbolSize: 5,
          itemStyle: {
            normal: {
              color: "#FF0000"
            }
          }
        })
      })

      l.forEach((item, index) => {
        options.lines.push({
          fromName: "",
          toName: "",
          coords: item,
          lineStyle: {
            normal: {
              color: `rgb(250, 152, 25)`,
              width: 1,
              opacity: 0.2,
              curveness: 0.1
            }
          }
        })
      })

      let citys = [...options.points, ...options.toPoints];

      return {
        amap: {
          viewMode: "3D",
          pitch: 45,
          center: options.center,
          zoom: 12,
          resizeEnable: true,
          renderOnMoving: false,
          mapStyle: "amap://styles/grey",
          echartsLayerInteractive: true,
          largeMode: false
        },
        series: [
          {
            name: "地点",
            type: "effectScatter",
            coordinateSystem: "amap",
            zlevel: 3,
            rippleEffect: {
              brushType: "stroke"
            },
            label: {
              emphasis: {
                show: true,
                position: "right",
                formatter: "{b}"
              }
            },
            symbolSize: 2,
            showEffectOn: "render",
            itemStyle: {
              normal: {
                color: "#74D4FF"
              }
            },
            data: citys
          },
          {
            name: "线路",
            type: "lines",
            coordinateSystem: "amap",
            zlevel: 4,
            large: true,
            effect: {
              show: true,
              constantSpeed: 30,
              symbol: "pin",
              symbolSize: 3,
              trailLength: 0
            },
            lineStyle: {
              normal: {
                color: () => {
                  return "#46bee9";
                },
                width: 1,
                opacity: 0.6,
                curveness: 0.1
              }
            },
            data: options.lines
          }
        ]
      };
    }
  </script>
</body>
</html>

@plainheart plainheart added bug Something isn't working and removed question Further information is requested waiting-for: author labels Jan 11, 2022
@plainheart
Copy link
Owner

@wenbei111 似乎 3D 模式下,用 lngLatToContainer 方法将不在可视区域的经纬度转为容器像素坐标会出现一些“异常”的结果,
[119.823825, 35.771387] -> { x: 477.20667343950913, y: -3521.877210937162 }。暂时不知道如何解决,只能先建议你不要使用 pitch

@plainheart plainheart added the help wanted Extra attention is needed label Jan 12, 2022
@wb-wenbei
Copy link
Author

好的,十分感谢!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants