waqasriaz / google-maps-utility-library-v3

Automatically exported from code.google.com/p/google-maps-utility-library-v3
Apache License 2.0
0 stars 0 forks source link

There are no zooming on 'clusterclick #53

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
There are no zooming on 'clusterclick'. There are no error in FireBug, but 
fitBounds() don't doing what have to do. I'm using jQuery in my project.

var map,
    markers = new Array(),
    clusterer,
    lat = 60,
    lng = 75,
    zoom= 2;

$(document).ready(function(){

   initialize();

   $("#btn-slct").click(function () {

        $.ajax({
            type: 'POST',
            url: 'http://somesite.ru/ajax/markers/get',
            dataType: 'json',
            data: {
              'query': 'bla-bla'
            },
            success: function(data){
                getMarkers(data);
                clusterer.clearMarkers();
                clusterer.addMarkers(markers);
            }
        });
   });
});

function initialize() {

    var center = new google.maps.LatLng(lat, lng);
    var options = {
        zoom: zoom,
        center: center,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById('gmap'), options);
    clusterer = new MarkerClusterer(map);

}

function getMarkers(ms){
    markers = [];
    $.each(ms, function(index, value) {
        markers.push(new google.maps.Marker({
            position: new google.maps.LatLng(value['lat'], value['lng'])
        }))
    });
}

Original issue reported on code.google.com by leafin...@gmail.com on 19 Nov 2010 at 4:01

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
to fix my problem i use following event listener

google.maps.event.addListener(clusterer, 'clusterclick', function (cluster) {
        var mrkrs = cluster.getMarkers();
        var bnds  = new google.maps.LatLngBounds();
        $.each(mrkrs, function(i, m){
            bnds.extend(m.getPosition());
        });
        map.fitBounds(bnds);
});

but i think it's not so good, as native "cluster zoom onClick"

Original comment by leafin...@gmail.com on 19 Nov 2010 at 4:45

GoogleCodeExporter commented 8 years ago
There is native zoomOnClick.

Line 991 
http://code.google.com/p/google-maps-utility-library-v3/source/browse/trunk/mark
erclusterer/src/markerclusterer.js

Do you have a link to your site that shows that it doesn't work? Because it 
works fine on the example - 
http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/e
xamples/simple_example.html

Original comment by lu...@google.com on 5 Dec 2010 at 11:03

GoogleCodeExporter commented 8 years ago

Original comment by lu...@google.com on 31 Mar 2011 at 6:02