1
すべてのラベルの言語をドイツ語に設定しようとしています。 これまでのところ私はいくつかのことを試みましたが、すべてが空白のマップになりました。 私はいくつかを含め、物事試してみました:mapboxリーフレットsetLayoutProperty
var language = "de";
var map = L.mapbox.map('map', 'mapbox.places', {worldCopyJump: true})
.setView([51.163375,10.447683], 6)
.addControl(L.mapbox.geocoderControl('mapbox.places', {
autocomplete: true,
keepOpen: true
}));
map.setLayoutProperty('country-label-lg', 'text-field', '{name_' + language + '}');
map.setLayoutProperty('country-label-md', 'text-field', '{name_' + language + '}');
map.setLayoutProperty('country-label-sm', 'text-field', '{name_' + language + '}');
と:また、スタイル&層をカスタマイズ
var language = "de";
var map = L.mapbox.map('map', 'mapbox.places', {worldCopyJump: true})
.setView([51.163375,10.447683], 6)
.setLayoutProperty('country-label-lg', 'text-field', '{name_' + language + '}')
.setLayoutProperty('country-label-md', 'text-field', '{name_' + language + '}')
.setLayoutProperty('country-label-sm', 'text-field', '{name_' + language + '}')
.addControl(L.mapbox.geocoderControl('mapbox.places', {
autocomplete: true,
keepOpen: true
}));
をそれらはすべてのマップを破りました。
glのドキュメントでは、いくつかのボタンで言語を変更する方法について (https://www.mapbox.com/mapbox-gl-js/example/language-switch/)があります。私はそれを自分のコードと違うものではないと考えました。
document.getElementById('buttons').addEventListener('click', function(event) {
var language = event.target.id.substr('button-'.length);
// Use setLayoutProperty to set the value of a layout property in a style layer.
// The three arguments are the id of the layer, the name of the layout property,
// and the new property value.
map.setLayoutProperty('country-label-lg', 'text-field', '{name_' + language + '}');
});
ええ、私は多くを考えました。しかし、リーフレットの言語を変更するためのドキュメントは見つかりません。 – Teuphil