Snippets

Piotr Szrajber Smart M.App - Override Tooltip Behavior

Created by Piotr Szrajber
function overrideTooltipBehavior(attempts) {
    $GP.bi.stage.findWidgets({
        descriptors: [{
            chartM: {
                chart: "choropleth"
            }
        }]
    }, function(widgets) {
        if (!widgets || !widgets[0]) {
            setTimeout(function() {
                if (attempts > 0) {
                    overrideTooltipBehavior(attempts - 1);
                }
            }, 300);
            return;
        }
        widgets[0].chart.willDoMouseEvent(function(feature, event) {
            if (event.type == 'click') {
                if (feature && feature.properties && feature.properties.imageUrl) {
                    var url = "https://s3.amazonaws.com/static-content.incidentanalyzer.mapp.hexagongeospatial.com/popup.html?imgSrc=" + feature.properties.imageUrl;
                    var a = document.createElement("a");
                    a.href = url;
                    a.target = "_blank";
                    document.body.appendChild(a);
                    a.click();
                }
            }
        });
    });
}

overrideTooltipBehavior(100);

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.