leaflet - 将叠加层添加到地图时如何将视图设置为叠加层?
问题描述
我正在将叠加层(下面代码中的“叠加层”)加载到传单底图(openstreetmap)上,并希望该叠加层在加载后完全填满显示窗口。
我认为我应该使用 getBounds 和 setView 使用通过 getBounds 获得的值,但没有设法使其工作。
// initialize the map
var map = L.map('map').setView([48.85, -3], 15);
// load a tile layer
L.tileLayer('https://{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png', {
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>',
minZoom: 3,
maxZoom: 18,
subdomains: 'abcd',
detectRetina : true
}).addTo(map);
//Load overlay
var overlayOptions = {
attribution: '...',
//minZoom: 3,
maxZoom: 19,
opacity: 1,
format: 'image/png',
detectRetina: true,
//unloadInvisibleTiles: true,
};
overlay = L.tileLayer('https://www.laurentgontier.com/BrehatSHOM/{z}/{x}/{y}.png', overlayOptions).addTo(map);
//fit map view to overlay bounds
map.fitBounds(overlay.getBounds());
到目前为止,应该将叠加层框入显示窗口的最后一行似乎不起作用。
解决方案
推荐阅读
- database - MongoDB在用户家庭地址上嵌入与参考?
- ios - validateNewTexture:89:缓冲区支持纹理的断言 `BytesPerRow 失败
- nginx - Vagrant 上的 Bolt CMS 不解析 PHP
- python - Django/DRF - prefetch_related() 在没有正确匹配外键关系的情况下返回所有对象?
- google-apps-script - 通过 Apps 脚本获得 Google Drive 权限——是否可以阻止编辑器下载或打印工作表?
- spring-cloud-stream - Spring Cloud Stream RabbitMQ 在死信队列上留下消息
- python - 如何找到包含 URL 数据的变量的字节数
- swift - 我可以使用 Xcode 11 在 Mojave 上编译 swift 5.1 吗?
- flutter - 使用图像选择器“无法加载资产”
- random - 如何将随机数生成器存储在结构中?