2016-02-12 51 views
1

我一直在试图动态地添加数据点到这里使用addDataPoints()addDataPoint()方法(我仍然不明白你为什么需要两种不同的方法.. )。addDataPoints在这里地图不工作

当我尝试使用他们,我得到这个错误:

Error: this.tb.push is not a function 
[email protected]://js.api.here.com/v3/3.0/mapsjs-core.js line 47 > eval:2:734 
[email protected]://js.api.here.com/v3/3.0/mapsjs-core.js line 47 > eval:24:52 
[email protected]://js.api.here.com/v3/3.0/mapsjs-core.js line 47 > eval:27:209 
[email protected]://localhost:3000/scripts/panel/controller.js:208:3 

populateCluster()是谁调用addDataPoints()函数,定义如下:

 clusterProvider = new H.clustering.Provider({}); 

     var poisFormattedAsDataPoint = poiManager.pois[category].map(function(poi){ 

      var tmpPoi = new H.clustering.DataPoint(poi.position[0], poi.position[1], null, poi); 
      return tmpPoi; 

     }); 

     clusterProvider.addDataPoints(poisFormattedAsDataPoint); 

     var clusteringLayer = new H.map.layer.ObjectLayer(clusterProvider); 

     map.addLayer(clusteringLayer); 

如果我添加的DataPoints在同一阵列提供者定义一切工作正常(我相信证明我使用的数据格式良好),但由于我必须动态添加点,所以这不是一个选项。

有没有人有这两个功能的工作示例?

非常感谢。

回答

1

我发现了这个错误。 我用一个空对象初始化提供程序,并应使用空数组进行初始化。所以

clusterProvider = new H.clustering.Provider({});

应该

clusterProvider = new H.clustering.Provider([]);

的问题是,是否应该允许初始化错误的一组数据的提供者?还是应该返回一个错误?

0

在我而言,这是不是让我来初始化像集群提供商没有clusteringOptions,但是当我提供clusteringOptions的工作:

clusterProvider = new H.clustering.Provider([], { 
     clusteringOptions: { 
     eps: 32, 
     minWeight: 2 
     } 
    });