我需要在更新地圖上顯示的地圖文件中的餅圖大小(在按鈕單擊上)後刷新一個拓撲圖地圖。我無法刷新整個頁面或丟失數據。它在我改變縮放級別時起作用。我試過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();
});
});