Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Behavior if no icon is found for cluster. #2

Open
donquixote opened this issue Jun 9, 2016 · 1 comment
Open

Behavior if no icon is found for cluster. #2

donquixote opened this issue Jun 9, 2016 · 1 comment

Comments

@donquixote
Copy link

Clusterer.PopUp = function(cluster){    
    var clusterer = cluster.clusterer;    
    var html = '<table width="300">';
    var n = 0;
    for (var i = 0; i < cluster.markers.length; ++i){
        var marker = cluster.markers[i];
        if (marker != null){
            ++n;
            var icon_marker = marker.getIcon();
            html += '<tr><td>';
            html += '<img src="' + icon_marker.url + '" width="' + (icon_marker.size.width / 2) + '" height="' + (icon_marker.size.height / 2) + '">';

If marker.getIcon() returns undefined, the method will blow up like this:

Uncaught TypeError: Cannot read property 'url' of undefined

This method fires a cluster is being clicked.

See also Clusterer2.js: marker.getIcon() returns null, and Clusterer.PopUp() blows up. in the drupal.org GMap issue queue.
I expect this is not an either-or, but both the Drupal module and the clusterer should add some sanity checks for early problem detection.

Btw, I remember having used the clusterer successfully in past projects, and having been happy with it. So something must have changed in the clusterer or in the Drupal module, or my setup is not correct. But even if my setup is not correct, adding some sanity checks can't be wrong.

Thanks!

@donquixote
Copy link
Author

Ok, this turned out to be a configuration issue. Somehow there was no marker configured.
But I still think this should be detected earlier with a meaningful message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant