【问题标题】:Here Map JS cluster marker remove option这里 Map JS 集群标记删除选项
【发布时间】:2019-09-24 07:14:51
【问题描述】:

在使用集群层显示标记的地图上,在 API 调用加载数据时重新加载我需要清除地图中的集群标记请帮助解决这个问题,使用当前方法清除普通标记(map.removeObjects(map.removeObjects(map.removeObjects(map.removeObjects)) getObjects()) 它作为例外工作,但我需要删除默认集群标记

请找到以下代码:

 startClustering(map, data) {
    // First we need to create an array of DataPoint objects,
    // for the ClusterProvider
    // tslint:disable-next-line:ter-prefer-arrow-callback
    const dataPoints = data.map(function (item) {
      console.log('item>>>>', item);
      return new H.clustering.DataPoint(item.y, item.x);
    });

    const clusteredDataProvider = new H.clustering.Provider(dataPoints, {
      clusteringOptions: {
        // Maximum radius of the neighbourhood
        eps: 1,
        // minimum weight of points required to form a cluster
        minWeight: 2,
      },
    });

    // Create a layer tha will consume objects from our clustering provider
    const clusteringLayer = new H.map.layer.ObjectLayer(clusteredDataProvider);
    // To make objects from clustering provder visible,
    // we need to add our layer to the map
    map.addLayer(clusteringLayer);

  }

我需要在调用这个函数之前删除这个簇标记

【问题讨论】:

    标签: here-api


    【解决方案1】:

    最简单的方法是保留对要删除的集群层的引用,然后通过以下方式将其删除:

    给定一个名为clusteringLayer的引用:

    map.removeLayer(clusteringLayer);

    使用map.getLayers() 检索所有地图图层并通过map.removerLayer(<layerRef>) 删除每个图层的另一种选择可能会删除您不想删除的图层。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-26
      • 2019-11-03
      • 1970-01-01
      • 2016-10-12
      • 1970-01-01
      • 2012-03-13
      相关资源
      最近更新 更多