1. 程式人生 > 實用技巧 >@react-native-mapbox-gl/maps語言外掛漢化不完善問題

@react-native-mapbox-gl/maps語言外掛漢化不完善問題

首先地圖使用URL使用以下版本:
mapbox://styles/mapbox/streets-v10
mapbox://styles/mapbox/outdoors-v10
mapbox://styles/mapbox/dark-v9
mapbox://styles/mapbox/light-v9
mapbox://styles/mapbox/satellite-streets-v9
mapbox://styles/mapbox/traffic-day-v2
mapbox://styles/mapbox/traffic-night-v2
然後修改原始碼,路徑 node_modules\@react-native-mapbox-gl\maps\android\rctmgl\src\main\java\com\mapbox\rctmgl\components\mapview\RCTMGLMapView.java

private void setupLocalization(Style style) {
mLocalizationPlugin = new LocalizationPlugin(RCTMGLMapView.this, mMap, style);
if (mLocalizeLabels) {
try {
mLocalizationPlugin.matchMapLanguageWithDeviceDefault();
localizationPlugin.setMapLanguage(MapLocale.CHINA);//可以根據需要修改,或者動態的設定語言
} catch (Exception e) {


final String localeString = Locale.getDefault().toString();
Logger.w(LOG_TAG, String.format("Could not find matching locale for %s", localeString));
}
}
}

網頁版本的語言外掛 https://github.com/mapbox/mapbox-gl-language