From 08e866d4aa8aaefc03a85826e73951d18a5a0eec Mon Sep 17 00:00:00 2001 From: Ryan Hamley Date: Fri, 5 Mar 2021 15:37:32 -0800 Subject: [PATCH] Update language when changing style --- index.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 1cedd87..dc35e8d 100644 --- a/index.js +++ b/index.js @@ -205,8 +205,6 @@ MapboxLanguage.prototype._initialStyleUpdate = function () { var style = this._map.getStyle(); var language = this._defaultLanguage || browserLanguage(this.supportedLanguages); - // We only update the style once - this._map.off('styledata', this._initialStyleUpdate); this._map.setStyle(this.setLanguage(style, language)); }; @@ -225,13 +223,13 @@ function browserLanguage(supportedLanguages) { MapboxLanguage.prototype.onAdd = function (map) { this._map = map; - this._map.on('styledata', this._initialStyleUpdate); + this._map.on('style.load', this._initialStyleUpdate); this._container = document.createElement('div'); return this._container; }; MapboxLanguage.prototype.onRemove = function () { - this._map.off('styledata', this._initialStyleUpdate); + this._map.off('style.load', this._initialStyleUpdate); this._map = undefined; };