[英]Limit zoom to a 'maximum' in d3 geo tiles
When you use certain tile-sets (eg .tiles.mapbox.com/v3/mapbox.natural-earth-2/
) the zoom on d3 geo tiles should be limited to a maximum, otherwise those tiles do not exist, cannot be found, and end up displaying an ugly 'cannot be found' background image. 当您使用某些图块集(例如
.tiles.mapbox.com/v3/mapbox.natural-earth-2/
)时,应将d3地理图块的缩放限制为最大,否则这些图块不存在,无法找到,最后显示难看的“找不到”背景图片。
I have created a fiddle (courtesy of user Lex ) to show you exactly what I mean. 我创建了一个小提琴 (由Lex提供 ),向您展示我的确切意思。 Try clicking on a small country to replicate the issue.
尝试单击一个小国家来复制该问题。 No tiles exist at that zoom level.
该缩放级别不存在图块。 The following two solutions would be acceptable.
以下两个解决方案是可以接受的。
clicked
that calculates the zoom-to-bounding-box? clicked
的放大功能,以计算缩放到边界框? clicked
continues to zoom into the most detailed tile available? clicked
功能继续放大到可用的最详细的图块? One easy approach to this is to limit the zoom by setting a maximum scaling factor. 一种简单的方法是通过设置最大缩放比例来限制缩放。
For instance in clicked
you could add a line like this: 例如在
clicked
您可以添加如下行:
scale = Math.min(1 << 14, scale);
(based your previous scale extent of [1 << 11, 1 << 14]
) (基于您以前的比例范围
[1 << 11, 1 << 14]
)
Here's the updated fiddle: https://jsfiddle.net/5Lf0w3sm/17/ 这是更新的小提琴: https : //jsfiddle.net/5Lf0w3sm/17/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.