Leaflet geoJson layers hidden outside viewport

不打扰是莪最后的温柔 提交于 2020-01-22 03:24:05

问题


I have a leaflet map with a few layers on it. Whenever layers are not in the viewport, they are hidden untill panning has completed:

Regular view with layers:

Panning right, to show layers outside viewport:

Panning stopped:

As illustrated above, the layers will first become visible once panning has stopped and mouse(finger) released.

I have tried the following, which didn't work

var map = L.map('map',{ bounceAtZoomLimits: false, removeOutsideVisibleBounds: false}).setView([40, 0], 2);
L.geoJson(mapData).addTo(map);

回答1:


Seems the solution was right in front of me

Adding the following will render the entire map:

var map = new L.Map('map');
map.getRenderer(map).options.padding = 100;

Solution found here



来源:https://stackoverflow.com/questions/51723916/leaflet-geojson-layers-hidden-outside-viewport

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!