我正在使用传单来显示原始行程以获得一些标记.我用传单折线显示我的行程.但我希望能够
如何在传单中隐藏和显示折线?
我可以做这个 :
$('.leaflet-overlay-pane').hide();
Run Code Online (Sandbox Code Playgroud)
和
$('.leaflet-overlay-pane').show();
Run Code Online (Sandbox Code Playgroud)
但这将显示并隐藏我的所有折线.我希望能够隐藏并单独显示它们.
谢谢.
小智 8
如果您有折线参考
var polyline = L.polyline(...);
Run Code Online (Sandbox Code Playgroud)
然后你可以使用
map.addLayer(polyline);//For show
map.removeLayer(polyline);// For hide
Run Code Online (Sandbox Code Playgroud)
目前我认为没有本地方法只能隐藏/显示,也许在0.7版本中
其他解决方案是在维护者的旧配件中访问对象容器
I don't think there's an easy solution, for tile layers at least. :( I'll try to handle this sooner.
For vectors, you can change path._container.style.display, and for markers - marker._image.style.display and marker._shadow.style.display.
Run Code Online (Sandbox Code Playgroud)