当前位置:网站首页>How does mapbox switch markup languages?

How does mapbox switch markup languages?

2022-07-07 05:31:00 ONEGISER(ZPC)

 Insert picture description here

 Insert picture description here

Preface

Someone asked how to make mapbox Support Chinese annotation ? The first thing that came to my mind mapbox Chinese net , His address is 《mapbox Chinese map address 》, Style is mapbox://styles/mapbox/streets-zh-v1. Later, it's not like this , Want to set it to Chinese , After inquiry , eureka Language setting plug-in , As for usage, see the documentation . Here is a brief introduction

import MapboxLanguage from '@mapbox/mapbox-gl-language';

const control = new MapboxLanguage({
    
            defaultLanguage: 'en'// default language 
        })
        map.addControl(control)
        setTimeout(() => {
    
        // switch language 
            const style = map.getStyle()
            const style2 = control.setLanguage(style, 'zh-Hans')
            map.setStyle(style2)
        }, 20000);
原网站

版权声明
本文为[ONEGISER(ZPC)]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202130734307249.html