1

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.

user10496245
  • 217
  • 3
  • 17
  • Please provide a [mcve] that demonstrates your issue. Although if you are using clustered markers and they are at the same location, that is the expected result (unless you use some kind of overlapping marker spiderfier, i.e. write code to deal with that) – geocodezip Nov 07 '18 at 13:59
  • Has any overlapping marker spiderfier for openlayers? – user10496245 Nov 08 '18 at 06:26
  • Not that I know of (but that doesn't mean there isn't one). There is one for the Google Maps Javascript API v3, you could look at porting that one. – geocodezip Nov 09 '18 at 01:27

1 Answers1

0

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: ????
      });
    }
  });
Mike
  • 16,042
  • 2
  • 14
  • 30