我找不到关于它的文档,请考虑:
// base map
L.tileLayer('http://tiles.mapc.org/basemap/{z}/{x}/{y}.png',
{
attribution: 'Tiles by <a href="http://mapc.org">MAPC</a>,
Data by <a href="http://mass.gov/mgis">MassGIS</a>',
maxZoom: 17,
minZoom: 9
}).addTo(map);
// bike lanes
L.tileLayer('http://tiles.mapc.org/trailmap-onroad/{z}/{x}/{y}.png',
{
maxZoom: 17,
minZoom: 9
}).addTo(map);
- 所以我们向 map 添加了两个 tile 图层,对吧?但是上面两个中的哪一个现在被设置为基础层呢? 一张 map 可以同时有多个基础图层吗? (因为我在某处读到基础层通常应该是相互排斥的)。
- 额外:我可以在不使用图层控制机制的情况下更改基础图层吗? (例如,仅以编程方式)。
最佳答案
So we added two tile layers to the map right? But which of the above two is set as a base layer now? Can a map have multiple base layers at once? (because I read somewhere base layers normally should be mutually exclusive).
是的,它们在显示上是互斥的,这意味着您一次只能显示一层。它没有记录,但添加的最后一层将成为正在显示的基础层。
Extra: Can I change a base layer without using the layer control mechanism? (e.g. only programatically).
是的,您可以使用 addLayer/removeLayer 方法。
map.removeLayer(base map layer name here);
map.addLayer(bike lane layer name here);
关于javascript - 两个瓷砖层中哪个是基础层,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42485283/