diff --git a/src/ui/map.js b/src/ui/map.js index 5dedc0bb661..ee4af8426d3 100755 --- a/src/ui/map.js +++ b/src/ui/map.js @@ -5,7 +5,17 @@ import {asyncAll, extend, bindAll, warnOnce, uniqueId, isSafariWithAntialiasingB import browser from '../util/browser.js'; import * as DOM from '../util/dom.js'; import {getImage, getJSON, ResourceType} from '../util/ajax.js'; -import {RequestManager, mapSessionAPI, getMapSessionAPI, postPerformanceEvent, postMapLoadEvent, AUTH_ERR_MSG, storeAuthState, removeAuthState} from '../util/mapbox.js'; +import { + RequestManager, + mapSessionAPI, + mapLoadEvent, + getMapSessionAPI, + postPerformanceEvent, + postMapLoadEvent, + AUTH_ERR_MSG, + storeAuthState, + removeAuthState +} from '../util/mapbox.js'; import Style from '../style/style.js'; import EvaluationParameters from '../style/evaluation_parameters.js'; import Painter from '../render/painter.js'; @@ -3891,6 +3901,7 @@ class Map extends Camera { } } }); + postMapLoadEvent(this._getMapId(), this._requestManager._skuToken, this._requestManager._customAccessToken, () => {}); } @@ -4014,6 +4025,7 @@ class Map extends Camera { removeAuthState(this.painter.context.gl); mapSessionAPI.remove(); + mapLoadEvent.remove(); this._removed = true; this.fire(new Event('remove')); diff --git a/src/util/mapbox.js b/src/util/mapbox.js index 9c1faf8b9eb..66e6c5cfd65 100644 --- a/src/util/mapbox.js +++ b/src/util/mapbox.js @@ -514,6 +514,11 @@ export class MapLoadEvent extends TelemetryEvent { }, customAccessToken); } + + remove() { + // $FlowFixMe[incompatible-type] + this.errorCb = null; + } } export class MapSessionAPI extends TelemetryEvent { @@ -657,9 +662,9 @@ const turnstileEvent_ = new TurnstileEvent(); // $FlowFixMe[method-unbinding] export const postTurnstileEvent: (tileUrls: Array, customAccessToken?: ?string) => void = turnstileEvent_.postTurnstileEvent.bind(turnstileEvent_); -const mapLoadEvent_ = new MapLoadEvent(); +export const mapLoadEvent: MapLoadEvent = new MapLoadEvent(); // $FlowFixMe[method-unbinding] -export const postMapLoadEvent: (number, string, ?string, EventCallback) => void = mapLoadEvent_.postMapLoadEvent.bind(mapLoadEvent_); +export const postMapLoadEvent: (number, string, ?string, EventCallback) => void = mapLoadEvent.postMapLoadEvent.bind(mapLoadEvent); export const performanceEvent_: PerformanceEvent = new PerformanceEvent(); // $FlowFixMe[method-unbinding]