Mapbox Tile Layer 中的街道标签太小 [英] Street labels in Mapbox Tile Layer too small
问题描述
我有以下传单地图:JSFiddle 链接
<div id="mapid" style="height: 300px;"></div>
<script>
var mapboxTiles = L.tileLayer(mapBoxUrl, {
attribution: attributionText
});
var map = L.map('mapid')
.addLayer(mapboxTiles)
.setView([42.888284, -78.877222], 16);
</script>
街道标签的字体非常小,以至于无法阅读,当您放大时,字体会变小.有没有办法控制字体大小?
The font size for the street labels is very small, to the point of being unreadable, and when you zoom in, the font size gets smaller. Is there a way to control the font size?
推荐答案
看起来你有 512px 大小的图块,但映射地球时好像它们是 256px 大小的.
It looks like you have 512px sized tiles, but mapping the Earth as if they were 256px sized.
因此,您需要 tileSize
和zoomOffset
选项在您的 Tile Layer 以补偿这些设置,并在图块上使用可读大小的文本检索正确的视图:
Therefore you need a combination of tileSize
and zoomOffset
options on your Tile Layer to compensate for these settings, and retrieve the correct view with readable sized text on the tiles:
var mapboxTiles = L.tileLayer(mapBoxUrl, {
attribution: '© <a href="https://www.mapbox.com/map-feedback/">Mapbox</a> © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>',
tileSize: 512,
zoomOffset: -1
});
更新的 JSFiddle:https://jsfiddle.net/zq02pnpg/2/
Updated JSFiddle: https://jsfiddle.net/zq02pnpg/2/
这篇关于Mapbox Tile Layer 中的街道标签太小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!