Javascript 更新图表元素后刷新openlayers地图

Javascript 更新图表元素后刷新openlayers地图,javascript,jquery,openlayers,Javascript,Jquery,Openlayers,在更新地图上显示的地图文件中饼图的大小(单击按钮)后,我需要刷新openlayers地图。我无法刷新整个页面,否则会丢失数据。当我更改缩放级别时,它会起作用。我尝试了map.updateSize()(无效果)、map.render()(未定义TypeError“a”)、layer.redraw()。我不确定我是否遗漏了与openlayers相关的内容,或者这是否是我的javascript的问题。我已经浏览了很多帖子,但似乎都没有找到适合我的答案 $(document).ready(functio

在更新地图上显示的地图文件中饼图的大小(单击按钮)后,我需要刷新openlayers地图。我无法刷新整个页面,否则会丢失数据。当我更改缩放级别时,它会起作用。我尝试了map.updateSize()(无效果)、map.render()(未定义TypeError“a”)、layer.redraw()。我不确定我是否遗漏了与openlayers相关的内容,或者这是否是我的javascript的问题。我已经浏览了很多帖子,但似乎都没有找到适合我的答案

$(document).ready(function() {
    map = new OpenLayers.Map( 'map' ,
    { maxExtent: new OpenLayers.Bounds({{bounds.0}}, {{bounds.1}}, {{bounds.2}}, {{bounds.3}}),
    controls:[new OpenLayers.Control.Navigation(),
               new OpenLayers.Control.LayerSwitcher(),
               new OpenLayers.Control.PanZoomBar()],
     numZoomLevels:20
     }
     );
     var mpLayer = new OpenLayers.Layer.MapServer('Zones Layer', '{{ mapserverpath }}', { 
                map:'{{mapFile}}',
                layers:'all',
                isBaseLayer: 'true'
                },{
                    singleTile: 'true'
//                  ratio: 2.0
                }
            );

    map.addLayers([mpLayer]);
    //map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
    map.zoomToMaxExtent();  

    map.events.register("click", map, qryDB );

    $(document).on('click', '#bttnMinus', function(){
        pieFact*=0.5;
        updatePieFact();
        mpLayer.redraw();
    });
    $(document).on('click', '#bttnPlus', function(){
        pieFact*=1.5;
        updatePieFact();
        mpLayer.redraw();
    });
    $(document).on('click', '#bttnReset', function(){
        pieFact=1.0;
        updatePieFact();
        mpLayer.redraw();
    });
});
您可以在重画之前尝试调用函数

“clearGrid()”是Layer.Grid的函数(Layer.MapServer继承自Layer.Grid)。它会破坏每一层的瓷砖

请注意,“clearGrid()”不是APIMethod,所以不应该以这种方式调用它


还有一个类似的问题/答案。

试试这个。这对我有用

$(window.trigger('resize')

此代码再次设置屏幕