I have more than 1000 markers at different location in my Map. I read Lat and Long from a xml file and render it in Google maps and create circle over them on the basis of city name within given radius. And count the number of markers in those circle.

Now what i want to do is?

(1) When the size of markers within the given radius greater then a predefined value such as 10 then i want to draw 2 small inner circles with smaller radius within the existed big circle.the smaller circles contains their own markers.So whenever marker size is less then the predefined value, i.e., 10 then it should combine the 2 radius of these two small circles and should show only one big circle covering the markers of the two smaller circles (smaller 2 will now disappear resulting on marker size is less then 10).

My code is:

function codeAddress() {
        var address = ["islamabad", "lahore", "karachi", "multan", "peshawar", "faisalabad"];  
        var radius = parseInt(document.getElementById('radius').value, 10)*1000;
var i=0;
for(i=0; i < address.length; i++ ){

        geocoder.geocode( { 'address': address[i]}, function(results, status) {
          if (status == google.maps.GeocoderStatus.OK) {
            side_bar_html = "";
            var searchCenter = results[0].geometry.location;
            if (circle) circle.setMap(null);
            circle = new google.maps.Circle({center:searchCenter,
                                             radius: radius,
                                             fillOpacity: 0.35,
                                             fillColor: "#FF0000",
                                             map: map});
            var bounds = new google.maps.LatLngBounds();
            var foundMarkers = 0;
            for (var i=0; i<gmarkers.length;i++) {
              if (google.maps.geometry.spherical.computeDistanceBetween(gmarkers[i].getPosition(),searchCenter) < radius) {
                side_bar_html += '<a href="javascript:myclick(' + i + ')">' + gmarkers[i].title + '<\/a><br>';
              } else {
            document.getElementById("side_bar").innerHTML = side_bar_html;
            if (foundMarkers > 0) {
        } else {

          } else {
            alert('Geocode was not successful for the following reason: ' + status);

var infowindow = new google.maps.InfoWindow(
    size: new google.maps.Size(300,200)

I don't want to use marker cluster, is there any other alternative solution.Could some one please help me in solving this problem? i just need to like this as shown in picture:circles with in circles

  • Welcome to GIS SE. It's not clear what your problem is. Can you include a diagram or example map to illustrate your problem? Please edit some extra info into the body of the question for clarification: e.g. Exactly how does the code relate to the question? And why are some lines commented out, not deleted? If we need to read your code, it should be very clean. – Martin F Apr 13 '15 at 18:10
  • Cross-posted from stackoverflow.com/q/29604656/820534 – PolyGeo Apr 13 '15 at 20:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.