plainheart / echarts-extension-gmap

🌎 A Google Map (https://www.google.com/maps) extension for Apache ECharts (https://github.com/apache/echarts)
https://github.com/plainheart/echarts-extension-gmap
MIT License
48 stars 8 forks source link

Lines problems #1

Closed Nevyn75 closed 3 years ago

Nevyn75 commented 4 years ago

Hi.

Could you please give me a small example on how to use Line type with your extension? I'm having some problems I think regarding series data format...

I keep getting the error: "TypeError: Cannot read property 'dataToPoint' of null"

Thank you very much!

Nevyn75 commented 4 years ago

Looking into your code I found this inside index.js:

import AMapCoordSys from "./GMapCoordSys";

import "./GMapModel";
import "./GMapView";

echarts.registerCoordinateSystem("amap", AMapCoordSys);

Maybe it's a problem because GMapCoordSys exports "GMapCoordSys"

Thank you.

plainheart commented 4 years ago

@Nevyn75 Thanks for your review! This is really helpful. It should be gmap but not amap. Fixed in https://github.com/plainheart/echarts-extension-gmap/commit/28334e9e59ff382eefb8d915ac7a6eba64aa2506 & 4d7525178ea4adc8634052d2caa37c3b43a6150b

plainheart commented 4 years ago

And for the error

"TypeError: Cannot read property 'dataToPoint' of null"

how does your test case look like?

Nevyn75 commented 4 years ago

Hi.

I already have echarts as dependency in my project.

I discover that your call to:

echarts.registerCoordinateSystem('gmap', GMapCoordSys)

was received by your echarts instance inside your dependencies (in your directory node_modules) and not in mine, so at the end 'gmap' coordinateSystem was not registered and that's why I had a null object.

To make it working I had to copy your js files into my project directly and now it seems ok.

If you could fix this, I would of course prefer to use your package as a module :-)

Thank you

plainheart commented 4 years ago

Hi, @Nevyn75 I've fixed this issue and released the new version 1.2.1 on NPM, please feel free to help to test it. Thank you very much.

helgasoft commented 3 years ago

Could you please provide working example with series type: 'line' ? Thank you.

plainheart commented 3 years ago

@helgasoft I'm sorry but only the series that supports the geo coordinate can work in this extension for Google Maps.

helgasoft commented 3 years ago

oops, wrong type - it's 'lines', not 'line'. This is supported in 'geo' (paste in Editor) :

option = {
  "yAxis": {  },  "xAxis": { "type": "category"  },
      "title": {
        "text": "DFW",
        "top": 30
      },
      "backgroundColor": "#191919",
      "geo": {
        "map": "world",
        "roam": true,
        "center": [-97.0372, 32.8959],
        "zoom": 4
      },
      "series": [
        {
          "type": "scatter",
          "coordinateSystem": "geo",
          "data": [
            {
              "value": ["-97.0372", "32.89595", "-106.60919", "35.04022", "AA", "DFW", "ABQ", "444"]
            },
            {
              "value": ["-97.0372", "32.89595", " -72.68323", "41.93887", "AA", "DFW", "BDL", "162"]
            },
            {
              "value": ["-97.0372", "32.89595", " -86.75355", "33.56294", "AA", "DFW", "BHM", "168"]
            }
          ],
          "symbolSize": 8
        },
        {
          "type": "lines",
          "coordinateSystem": "geo",
          "data": [
            {
              "coords": [
                ["-97.0372", "32.89595"],
                ["-106.60919", "35.04022"]
              ]
            },
            {
              "coords": [
                ["-97.0372", "32.89595"],
                [" -72.68323", "41.93887"]
              ]
            },
            {
              "coords": [
                ["-97.0372", "32.89595"],
                [" -86.75355", "33.56294"]
              ]
            }
          ],
          "lineStyle": {
            "curveness": 0.3,
            "width": 2,
            "color": "red"
          }
        }
      ]
};

Any similar example for this library ?

plainheart commented 3 years ago

@helgasoft Here is the demo: https://codepen.io/plainheart/pen/VwpqOYV

helgasoft commented 3 years ago

@plainheart, thank you!
My mistake was to use example from the Readme.md where each point has 3 elements [lng,lat,value]. When using type:'lines' however, parameter coords accepts only two [lng,lat], otherwise lines are not drawn.

neoayi commented 3 years ago

@plainheart 请问一下,目前这个插件貌似不支持 polyline = true, 即多线段绘制属性。是吗

plainheart commented 3 years ago

@neoayi 应该是可以的。这里有个示例:https://codepen.io/plainheart/pen/LYybaxW

neoayi commented 3 years ago

感谢指正。应该是对数据有要求。必须大于2的数据才能实现多点连线。

Zhongxiang.Wang @.***> 于2021年7月13日周二 下午3:25写道:

@neoayi https://github.com/neoayi 应该是可以的。这里有个示例: https://codepen.io/plainheart/pen/LYybaxW

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/plainheart/echarts-extension-gmap/issues/1#issuecomment-878845949, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABBVMYNUMUSW5TBW7VHFG3TXPS53ANCNFSM4RYCEUYQ .

--

黄明

msn: @.***

上海携恒物流技术有限公司

地址 : 上海市冠生园路 227号 2号楼 206室 邮编 : 200231