2016-02-12 53 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 
     } 
    });