简体   繁体   English

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

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

I'm trying to create a popup, but first time I do not get the right style. 我正在尝试创建一个弹出窗口,但是第一次我没有正确的样式。 What I can be doing wrong? 我可能做错了什么?

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

My html. 我的HTML。

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

My JavaScript code 我的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);
            }
        });
    }
});

I don't know what am I doing wrong? 我不知道我在做什么错?

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

I've found the answer. 我找到了答案。

I've change responsive options to false of my Chartjs config 我已将我的Chartjs配置的响应选项更改为false

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

相关问题 当网站开放但第一次打开时,PHp会打开弹出窗口 - PHp open popup window when website is open but only first time 当我打开模式弹出窗口以显示地图时,第一次加载地图 - When I open modal popup to show map, the first time map is loaded 在我创建的mapbox.js地图上,“以编程方式打开弹出窗口”按钮不起作用 - The “open popup programmatically” button not working on my mapbox.js map I have created 上 <div> 悬停,我如何找到相关的Mapbox标记,更改其颜色,并打开弹出窗口? - On <div> hover, how do I find the associated Mapbox marker, change its color, and open popup? 打开弹出窗口时加载代码 - Load code when I open a popup 将鼠标悬停在Mapbox中的Popup上时,Mousemove停止触发 - Mousemove stops triggering when hovering on Popup in Mapbox Mapbox:通过在地图外部单击来打开标记的弹出窗口 - Mapbox: Open a marker's popup by clicking outside the map Mapbox 搜索,打开弹出窗口/工具提示并更改自定义标记图像 - Mapbox search, open popup/tooltip and change the custom marker image Yii2:打开ajax弹出窗口时未加载JS脚本 - Yii2: Not loading JS scripts when I open an ajax popup 单击以打开另一个窗口时如何强制关闭弹出窗口? - How to force popup to close when I click to open an other one?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM