javascript - hide div 上的传单 map

标签 javascript dictionary hide hidden leaflet

我知道有一些与此相关的主题,但我仍然无法管理它。

$(document).ready(function(){
            var map = L.map('map',{
                center:[30.0,0.0],
                zoom: 2,
            });

            L.tileLayer('http://{s}.tiles.mapbox.com/v3/mboucas.ilm9bh3m/{z}/{x}/{y}.png', {
                attribution: '',
                maxZoom: 18
            }).addTo(map);

            var markers = new L.MarkerClusterGroup();

            var points_rand = L.geoJson(points, {
                onEachFeature: function (feature, layer)
                {
                    var marker = L.marker(feature.geometry.coordinates);
                    markers.addLayer(marker);
                }   
            });

            map.addLayer(markers);

            map.fitBounds(markers.getBounds());

            $("#map").hide();

            $("#buttonmap").click(function(){ 

                $("#map").slideDown();
                map.invalidateSize(false);
                map.fitBounds(markers.getBounds());

            });

            $(".container").hover(function(){ 

            },function(){ 
                if($("#map").css("display")=="block") 
                { 
                    $("#map").slideUp(); 
                } 
            }); 
        });

我已经尝试了一切

map.invalidateSize()

L.Util.requestAnimFrame(map.invalidateSize, map, false, map._container)

setTimeout(function(){ map.invalidateSize()}, 400)

没有任何作用。

请帮帮我

感谢您的帮助。

最佳答案

我遇到了类似的问题,试试这个:

map._onResize();

这将强制调整 map 大小。

关于javascript - hide div 上的传单 map ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24547468/

相关文章:

php - 加载时显示页面

javascript - 使用 jQuery,当我在输入框外部单击时如何更改输入元素的值?

javascript - addClass 和 removeClass 方法无法正常工作

javascript - Discord - 从 javascript 中的列表中选择

python - 类型错误 : 'dict' does not Support the Buffer Interface

python - 在 json 序列化期间评估字典值

python - 如何在Python中并排打印两个计数器?

php - 重写文件扩展名但拒绝直接访问文件

Javascript数组排序比较函数奇怪的排序

hide - 在 Visio 的 Stencil 中隐藏主控形状