首页 > 代码库 > leaflet地图在选项卡中不正常显示

leaflet地图在选项卡中不正常显示

可以在选项卡中加个click事件,调用下

<a href=http://www.mamicode.com/"#tab1" >tab1</a>
<a href=http://www.mamicode.com/"#tab2" onclick="$.expandMap();">tab2</a
>

var map = null;
$(function(){
//加载gis地图
var southWest = L.latLng(*, *),
northEast = L.latLng(*, *),
bounds = L.latLngBounds(southWest, northEast);

map = L.map(‘ExampleMap‘, {
zoomControl: true,
attributionControl: false,//隐藏copyright
maxBounds: bounds,
minZoom: 9,
maxZoom: 12,
invalidateSize:true
}).setView([*, *], 9);
console.log(‘test‘);
new L.TileLayer.TileLoad(‘./maps/NJBaseMap‘).addTo(map);
})


$.expandMap = function() {
L.Util.requestAnimFrame(map.invalidateSize,map,!1,map._container);
}
 
 

leaflet地图在选项卡中不正常显示