繁体   English   中英

第一次打开弹出窗口时(Mapbox)

[英]First time when I open a popup (Mapbox)

我正在尝试创建一个弹出窗口,但是第一次我没有正确的样式。 我可能做错了什么?

var canvas = document.getElementById("canvas");

我的HTML。

<canvas id='canvas' style="min-width: 600px; margin: -4px"></canvas>

我的JavaScript代码

map.on('click', 'region-capa', function (e) {
    if (typeof myChart != 'undefined') {
        myChart.destroy();
    }
    if (e) {
        nombre = e.features[0].properties.SST_NOMBRE;
        $.ajax({
            type: "GET",
            url: "/Mapa/GetEstadisticas/" + parseInt(e.features[0].properties.SST_ID),
            contentType: "application/json",
            dataType: "json",
            success: function (response) {
                if (response) {
                    grafica(response);
                    new mapboxgl.Popup({ closeButton: true, closeOnClick: true })
                        .setLngLat(e.lngLat)
                        .setDOMContent(canvas)
                        .addTo(map);
                }
            },
            failure: function (response) {
                alert(response);
            }
        });
    }
});

我不知道我在做什么错?

我得到的示例: https : //user-images.githubusercontent.com/2707903/35266189-c11f0856-0022-11e8-9a4e-0e8c2a8420a0.JPG

我找到了答案。

我已将我的Chartjs配置的响应选项更改为false

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM