Update index.ts

This commit is contained in:
Parry 2019-12-17 16:05:33 +08:00 committed by GitHub
parent bcb63ff68d
commit c03c9cebde
1 changed files with 11 additions and 3 deletions

View File

@ -202,20 +202,28 @@ export default class MapboxService
* TODO: 使用 mapbox v0.53.x custom layer gl context
* @see https://github.com/mapbox/mapbox-gl-js/blob/master/debug/threejs.html#L61-L64
*/
if (!mapboxgl) {
// 判断全局 mapboxgl 对象的加载
if (!('mapInstance' in this.config) && !mapboxgl) {
// 用户有时传递进来的实例是继承于 mapbox 实例化的,不一定是 mapboxgl 对象。
this.logger.error(this.configService.getSceneWarninfo('SDK'));
}
if (
token === MAPBOX_API_KEY &&
style !== 'blank' &&
!mapboxgl.accessToken
!mapboxgl.accessToken &&
!('mapInstance' in this.config) // 如果用户传递了 mapInstance应该不去干预实例的 accessToken。
) {
this.logger.warn(this.configService.getSceneWarninfo('MapToken'));
}
if (!mapboxgl.accessToken) {
// 判断是否设置了 accessToken
if ('mapInstance' in this.config && !mapboxgl.accessToken) {
// 用户有时传递进来的实例是继承于 mapbox 实例化的,不一定是 mapboxgl 对象。
mapboxgl.accessToken = token;
}
if (mapInstance) {
// @ts-ignore
this.map = mapInstance;