Fix using api which is not ready
This commit is contained in:
parent
f4ac9edad7
commit
2208d3621d
@ -81,17 +81,22 @@ export default class MapViewModel extends ViewModel {
|
|||||||
* @param {string} apiName API name
|
* @param {string} apiName API name
|
||||||
*/
|
*/
|
||||||
loadMapAPI(apiName) {
|
loadMapAPI(apiName) {
|
||||||
if (this.api) {
|
let mapApi = this.api;
|
||||||
|
this.api = null;
|
||||||
|
if (mapApi) {
|
||||||
try {
|
try {
|
||||||
this.savedBounds = this.api.getBounds();
|
this.savedBounds = mapApi.getBounds();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.savedBounds = null;
|
this.savedBounds = null;
|
||||||
}
|
}
|
||||||
this.api.cleanup();
|
mapApi.cleanup();
|
||||||
}
|
}
|
||||||
this.api = this.getApi(apiName);
|
mapApi = this.getApi(apiName);
|
||||||
this.api.init()
|
mapApi.init()
|
||||||
.then(() => this.onReady())
|
.then(() => {
|
||||||
|
this.api = mapApi;
|
||||||
|
this.onReady();
|
||||||
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
let txt = $._('apifailure', apiName);
|
let txt = $._('apifailure', apiName);
|
||||||
if (e && e.message) {
|
if (e && e.message) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user