Is there any way to see when several placemarks su

2019-09-06 02:17发布

问题:

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.