0

Using gmaps.js and having an issue with marker clustering... it works perfectly fine although in my case I may have markers with the exact same location (lat/lng).

What happens is when you zoom to the highest level the cluster disappears and there are no markers shown at all (I thought they would be layered over each other so at lease one is viewable, but that is not the case for me). I have found some solutions on here which change the lat/lng values slightly so each marker has a different location, but in reality like 100 meters difference or something. I think this would work find in my situation, but I do not know how to implement these solutions since I am using gmaps.js.

Current working code, but the problem mentioned above :

response.results in an array of my location data retrieve with ajax...

//create the map
map = new GMaps({
    el: '#map_canvas_main',
    lat: response.results[0].lat,
    lng: response.results[0].lng,
    panControl : false,
    markerClusterer: function(map) {
        return new MarkerClusterer(map);
    }
});

//loop through array
for(var i = 0; i < response.results.length; i++)
{
    //add marker
    map.addMarker({
        lat: response.results[i].lat,
        lng: response.results[i].lng,
        title: response.results[i].ip_address,
        infoWindow: {
          content: '<p>'+response.results[i].ip_address+'</p>'
        }
    }); 
}

EDIT :

I added a fiddle mimicking multiple markers at the same location. Strangely in the fiddle the 'cluster marker' does not disappear yet in my site it does. What happens on my site is you can zoom in on the marker any way you want... when you reach the highest zoom level and click on it... it disappears. You need to zoom out or pan around for the image to come back. This does not happen in the fiddle though.

Regardless of that though - I still need a method in which to show the information for all the markers in the same location... most of the solution I found here on SO change the lat/lng ever so slightly to avoid this...

so link

fiddle

Community
  • 1
  • 1
user756659
  • 3,372
  • 13
  • 55
  • 110
  • can you create a fiddle out of it? have not used gmaps.js before - but check gridsize options http://jsfiddle.net/iambnz/203c9d4w/ – hwsw Sep 28 '14 at 14:44
  • Possibly related: http://stackoverflow.com/questions/3548920/google-maps-api-v3-multiple-markers-on-exact-same-spot – Bjorn Sep 28 '14 at 18:43
  • Yes, I looked at that before and it is somewhat similar, however, I am using the gmaps.js script in conjunction with the v3 api. The answer by Ignatius is preferably what I would prefer to do... if max zoom is reached and still clustered then on click provides a popup with info. I agree with the comments about NOT changing the lat/lng... realizing it could cause more problems than good. – user756659 Sep 28 '14 at 23:34

0 Answers0