Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public async canLoad(
route: Route,
segments: UrlSegment[]
): Promise {
if (isLoaded()) {
return true;
}
try {
const options = this.getOptions();
// load esri script and dojoConfig;
await loadScript(options);
// add cors enabled hosts
const [config] = await loadModules(['esri/config']);
for (const server of environment.trustedServers) {
config.request.trustedServers.push(server);
}
return true;
}
catch (ex) {
console.error(ex);
return false;
return new Promise((resolve, reject) => {
const cdn = global.options.cdn
if (cdn !== undefined && global.loaded) {
// Has the ArcGIS API been added to the page?
if (!esriLoader.isLoaded()) {
// No, lazy load it the ArcGIS API before using its classes
esriLoader.bootstrap(err => {
if (err) {
logger.error(err)
}
// Once it's loaded, create the map
logger.log(`Waiting ESRI server...`)
dojoLoader(resolve, reject)
}, {
// Use a specific version instead of latest 4.x
url: cdn
})
} else {
// ArcGIS API is already loaded, just create the map
logger.log(`Waiting ESRI server...`)
dojoLoader(resolve, reject)
isLoaded() {
return isLoaded();
}
isLoaded() {
return isLoaded();
}
isLoaded() {
return isLoaded();
}
unknownProperty (key) {
if (key === 'isLoaded') {
return esriLoader.isLoaded();
}
},