Skip to content

Commit 2bf7517

Browse files
committed
Fixed getGlobalStateForLocalization example
Setting the state upfront doesn’t work; need to call Map.prototype.setGlobalStateProperty() on each individual property.
1 parent 52514d9 commit 2bf7517

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,17 @@ Parameters:
190190
Example:
191191

192192
```js
193-
style.state = maplibregl.getGlobalStateForLocalization(locales, { uppercaseCountryNames: true }),
193+
map.once("styledata", (event) => {
194+
let localizationState = maplibregl.Diplomat.getGlobalStateForLocalization(
195+
getLocales(),
196+
{
197+
uppercaseCountryNames: true,
198+
},
199+
);
200+
for (let [key, value] of Object.entries(localizationState)) {
201+
map.setGlobalStateProperty(key, value);
202+
}
203+
});
194204
```
195205

196206
### `maplibregl.Diplomat.getLocales()`

0 commit comments

Comments
 (0)