Mapbox Tile Layer中的街道标签太小 [英] Street labels in Mapbox Tile Layer too small

查看:38
本文介绍了Mapbox Tile Layer中的街道标签太小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下传单地图: 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?

推荐答案

您似乎拥有512像素大小的图块,但将地球映射为256像素大小.

It looks like you have 512px sized tiles, but mapping the Earth as if they were 256px sized.

因此,您需要将 tileSize 和<瓷砖图层上的href ="http://leafletjs.com/reference.html#tilelayer-zoomoffset" rel ="noreferrer"> zoomOffset 选项以补偿这些设置,以及检索图块上具有可读大小的文本的正确视图:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆