Here api 集群标记上的过滤器[此处映射JS API]

Here api 集群标记上的过滤器[此处映射JS API],here-api,Here Api,我用getClusterPresentation和getNoisePresentation创建了一个包含许多聚集标记的地图 我的数据设置如下: { address: "Store 1 address", brands:["BRAND1", "BRAND4"], lat: "40.82346", lng: "5.2345", name: "Store 1 Name" }, { address: "Store 2 address", brands:["BRAND2", "BRAND4

我用
getClusterPresentation
getNoisePresentation
创建了一个包含许多聚集标记的地图

我的数据设置如下:

{
 address: "Store 1 address",
 brands:["BRAND1", "BRAND4"],
 lat: "40.82346",
 lng: "5.2345",
 name: "Store 1 Name"
}, 
{
 address: "Store 2 address",
 brands:["BRAND2", "BRAND4"],
 lat: "40.82346",
 lng: "5.2345",
 name: "Store 2 Name"
}, 
我需要按品牌创建一个过滤器,以显示/隐藏我的标记。我不知道怎么做。如何访问具有特定品牌(例如:“BRAND2”)的特定集群标记并控制其可见性


感谢您在创建新的
H.clustering.DataPoint
时提供的帮助,您可以指定可选参数opt_data,该参数将与给定数据点关联。有关数据点的更多信息,请参阅:。 然后
getNoisePresentation
回调中的noisePoint将包含此数据,您可以通过调用
getData()
方法来访问它

// assume data is stored in "data" array, create new DataPoints array:
data.forEach(function(obj) {
  points.push(new H.clustering.DataPoint(obj.lat, obj.lng, undefined, obj));
})
.
.
.
// now we can work with this data in getNoisePresentation callback:
getNoisePresentation: function(noisePoint) {
  let data = noisePoint.getData(),
      visibility = data['brands'].includes('BRAND2');
  return new H.map.Marker(noisePoint.getPosition(), {
    min: noisePoint.getMinZoom(),
    visibility  
  });
}

在这里,您可以找到一个完整的工作示例,如果地图放大,它会隐藏一个噪声点(存储1)。

非常感谢!我会尽快试一试。