Is there any way to see when several placemarks superimposed on the same positions?

拥有回忆 提交于 2020-01-07 02:43:22

问题


Is there any way to see when several placemarks superimposed on the same positions?

As the figure below, Google Earth, we have a way to see it. Thank you.


回答1:


Yes, you can use your imagination and make a custom cluster. See this plunker demo, I use the following function to create a cluster like:

var displayOverlapping = function(pixel) {

  var f = map.forEachFeatureAtPixel(pixel, function(ft, l) {
      return ft;
  });
  if (f && f.get('type') == 'cluster') {

    if(f.get('expanded') === true) return;

    var geom = f.getGeometry(),
        coord = geom.getCoordinates(),
        px = map.getPixelFromCoordinate(coord),
        extent = [coord[0], coord[1], coord[0], coord[1]],
        ar_features = [];

    sourceFeatures.forEachFeatureInExtent(extent, function(ft){
        if(ft.get('type') == 'click') ar_features.push(ft);
    });
    var angle = (100 / ar_features.length) * 3.6;

    f.set('expanded', true);
    f.setStyle(style_cluster_hover);
    multiLineString.setCoordinates([]);

    ar_features.forEach(function(row, index){
      var angle2 = index * angle,
          px_end = rotate(px[0], px[1], angle2, 30),
          cd_end = map.getCoordinateFromPixel(px_end);

      multiLineString.appendLineString(
          new ol.geom.LineString([coord, cd_end])
      );

      row.setGeometry(new ol.geom.Point(cd_end));
      row.setStyle(style_parada);
    });
  }
};

The function is triggered on pointermove event.



来源:https://stackoverflow.com/questions/35866107/is-there-any-way-to-see-when-several-placemarks-superimposed-on-the-same-positio

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!