问题主要出现在mapboxgl的字体没有引入进来,先查看字体引入情况在地图初始化的位置查看路径是否正确

glyphs:

this.map = new mapboxgl.Map({
        container: domId,
        style: {
          "version": 8,
          "sprite": localhost + "/css/sprite",
          "glyphs": localhost + "/css/font/{fontstack}/{range}.pbf",
          "sources": {},
          "layers": [],
        },
        center: window.g.center,
        zoom: window.g.zoom,
        pitch: 0,  //地图的角度,不写默认是0,取值是0-60度,一般在3D中使用
        bearing: 0, //地图的初始方向,值是北的逆时针度数,默认是0,即是正北
        antialias: true, //抗锯齿,通过false关闭提升性能
      });

然后在对应的addLayer位置查看当前字体库内是否有改字体包

this.map.addLayer({
      "id": "Pointgrid",
      "type": "symbol",
      "source": "gridPoint",      
      'layout': {
          'text-field': ['get', 'name'],
          'text-font': [
            'Microsoft YaHei Regular'//该处是否填写正确
            ],
          'text-offset': [0, 1.25],
          'text-anchor': 'bottom',
          "text-size": [
            "interpolate",
            ["linear"],
            ["zoom"],
            4, 9,
            6, 12
          ]
      },
      "paint": this.style.point
    })

没有问题时则问题解决,不会报错message: "Unimplemented type: 4"

Logo

分享最新的 NVIDIA AI Software 资源以及活动/会议信息,精选收录AI相关技术内容,欢迎大家加入社区并参与讨论。

更多推荐