AmCharts地图。加载后显示数据画面

时间:2018-12-10 23:49:36

标签: javascript typescript angular5 amcharts ammap

我的应用程序中有一些amCharts(第3版)地图,其中包含大量数据(引脚)。我希望它加载数据而不冻结页面。我可以通过哪种方式实现这一点。我正在尝试proccessTimeout,setInterval,setTimeout。没有任何帮助。

1 个答案:

答案 0 :(得分:2)

amMaps 3并未针对处理大量数据进行优化。您可以尝试几种解决方法,以帮助提高性能,但这不是100%的修复,如果数据量很大,可能会达到上限。

一个选项是创建一个多级向下钻取,您可以在其中以区域标记的形式显示较小的数据子集。当用户单击其中之一时,将显示基础数据点,例如:

  "dataProvider": {
    "map": "usa2Low",
    "images": [ {
      "svgPath": targetSVG,
      "label": "San Diego", //Clicking on the San Diego marker 
      "zoomLevel": 14,      //will reveal markers for Imperial Beach, El Cajon, etc
      "scale": 1,
      "title": "San Diego",
      "latitude": 32.715738,
      "longitude": -117.161084,
      "images": [ {
        "svgPath": targetSVG,
        "scale": 0.7,
        "title": "Imperial Beach",
        "latitude": 32.586299,
        "longitude": -117.110481
      }, {
        "svgPath": targetSVG,
        "scale": 0.7,
        "title": "El Cajon",
        "latitude": 32.802417,
        "longitude": -116.963539
      }, {
        "svgPath": targetSVG,
        "scale": 0.7,
        "title": "University City",
        "latitude": 32.861268,
        "longitude": -117.210045
      }, {
        "svgPath": targetSVG,
        "scale": 0.7,
        "title": "Poway",
        "latitude": 32.969635,
        "longitude": -117.036324
      } ]
    } ]

下面是一个示例:https://www.amcharts.com/docs/v3/tutorials/map-marker-drill-down/

另一种选择是使用groupIdzoomLevel仅在特定缩放级别上显示某些数据点,这将最初需要渲染的点数减至最少,直到用户寻找更多细节为止。到上一个示例,但不使用嵌套结构:

  "dataProvider": {
    "map": "worldLow",
    "images": [ {
      "groupId": "minZoom-2", //minZoom-2 group of images, visible at zoomLevel 5
      "svgPath": targetSVG,
      "zoomLevel": 5,
      "scale": 0.5,
      "title": "Vienna",
      "latitude": 48.2092,
      "longitude": 16.3728
    }, 
    // ... other images with group minZoom-2 omitted
    // ...
     {
      "groupId": "minZoom-2.5", //minZoom-2.5 group, visible at 
      "svgPath": targetSVG,
      "zoomLevel": 5,
      "scale": 0.5,
      "title": "Pyinmana",
      "latitude": 19.7378,
      "longitude": 96.2083
    }, 
    // ... etc

// create a zoom listener which will check current zoom level and will toggle
// corresponding image groups accordingly
map.addListener( "rendered", function() {
  revealMapImages();
  map.addListener( "zoomCompleted", revealMapImages );
} );

function revealMapImages( event ) {
  var zoomLevel = map.zoomLevel();
  if ( zoomLevel < 2 ) {
    map.hideGroup( "minZoom-2" );
    map.hideGroup( "minZoom-2.5" );
  } else if ( zoomLevel < 2.5 ) {
    map.showGroup( "minZoom-2" );
    map.hideGroup( "minZoom-2.5" );
  } else {
    map.showGroup( "minZoom-2" );
    map.showGroup( "minZoom-2.5" );
  }
}

下面是一个示例:https://www.amcharts.com/docs/v3/tutorials/show-groups-map-images-specific-zoom-level/