javascript - 两个瓷砖层中哪个是基础层

标签 javascript leaflet

我找不到关于它的文档,请考虑:

// 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/

相关文章:

leaflet - 可以删除带有图像的传单链接

javascript - 为什么我在 osm 中收到此错误?

传单:如何处理重叠的线条?

javascript - 如何使用 window.scroll 在页面加载时自动滚动?

javascript - 定期刷新 jQuery 中的 <img>

javascript - 这两个 Angular 代码片段有什么区别?

javascript - 来自插件的 dcjs.leaflet Choropleth 中的弹出窗口不起作用

javascript - 如何将日期转换为 HTML 中的单词

javascript - 在 h1 标签上移动时闪烁

r - 如何下载geojson数据并将其读取到R