Please tell us first what framework you are using to display the map … Leaflet? Openlayers? khtml?

As far as I know, the feature you are asking for is named “clustering” … maybe an internet search for this in connection with your framework’s name can help.