In openlayers multiple markers at same lat and long not showing all markers

1.1k views Asked by At

I am using openlayers to show markers in map but the markers with same lat and long doesn't show instead it shows the picture below:

markers as count

I am expecting that when I zoom in it shows markers as pushpins but it only shows like the picture above.

1

There are 1 answers

0
Mike On

If two features are at exactly the same location one would inevitably be hidden behind the other no matter how much you zoom in. If you are using clusters you could display the names (or some other property) of each feature in the cluster instead of a count, for example:

  var clusters = new ol.layer.Vector({
    source: clusterSource,
    style: function(cluster) {
      var text = '';
      cluster.get('features').forEach(
        function(feature) { text += feature.get('name') + '\n' }
      );
      return new ol.style.Style({
        text: new ol.style.Text({
          text: text,
          fill: ????
        }),
        image: ????
      });
    }
  });