Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
initialize: function (options) {
// L.Layer expects a JSON object literal to be passed in constructor
options = {
id: options
};
if (typeof options.id === 'string') {
var itemMetadataUrl = Layer.URLPREFIX + options.id;
var tileUrl;
var styleUrl;
request(itemMetadataUrl, {}, function (error, metadata) {
if (!error) {
tileUrl = metadata.url;
// custom tileset published using ArcGIS Pro
if (tileUrl.indexOf('basemaps.arcgis.com') === -1) {
this._customTileset = true;
// if copyright info was published, display it.
if (metadata.accessInformation) {
this._copyrightText = metadata.accessInformation;
}
request(tileUrl, {}, function (error, tileMetadata) {
if (!error) {
// right now ArcGIS Pro published vector services have a slightly different signature
if (tileMetadata.defaultStyles.charAt(0) !== '/') {
tileMetadata.defaultStyles = '/' + tileMetadata.defaultStyles;
}
request(itemMetadataUrl, {}, function (error, metadata) {
if (!error) {
tileUrl = metadata.url;
// custom tileset published using ArcGIS Pro
if (tileUrl.indexOf('basemaps.arcgis.com') === -1) {
this._customTileset = true;
// if copyright info was published, display it.
if (metadata.accessInformation) {
this._copyrightText = metadata.accessInformation;
}
request(tileUrl, {}, function (error, tileMetadata) {
if (!error) {
// right now ArcGIS Pro published vector services have a slightly different signature
if (tileMetadata.defaultStyles.charAt(0) !== '/') {
tileMetadata.defaultStyles = '/' + tileMetadata.defaultStyles;
}
styleUrl = tileUrl + tileMetadata.defaultStyles + '/root.json';
request(styleUrl, {}, function (error, style) {
if (!error) {
formatStyle(style, tileMetadata, styleUrl);
this._mapboxGL = L.mapboxGL({
accessToken: 'ezree',
style: style
});
request(tileUrl, {}, function (error, tileMetadata) {
if (!error) {
// right now ArcGIS Pro published vector services have a slightly different signature
if (tileMetadata.defaultStyles.charAt(0) !== '/') {
tileMetadata.defaultStyles = '/' + tileMetadata.defaultStyles;
}
styleUrl = tileUrl + tileMetadata.defaultStyles + '/root.json';
request(styleUrl, {}, function (error, style) {
if (!error) {
formatStyle(style, tileMetadata, styleUrl);
this._mapboxGL = L.mapboxGL({
accessToken: 'ezree',
style: style
});
this._ready = true;
this.fire('ready', {}, true);
}
}, this);
}
}, this);
} else {
export function fetchMetadata (url, context) {
request(url, {}, function (error, style) {
if (!error) {
request(style.sources.esri.url, {}, function (error, tileMetadata) {
if (!error) {
formatStyle(style, tileMetadata, url);
context._mapboxGL = L.mapboxGL({
accessToken: 'ezree',
style: style
});
context._ready = true;
context.fire('ready', {}, true);
}
}, context);
} else {
throw new Error('Unable to fetch vector tile style metadata');
}
request(url, {}, function (error, style) {
if (!error) {
request(style.sources.esri.url, {}, function (error, tileMetadata) {
if (!error) {
formatStyle(style, tileMetadata, url);
context._mapboxGL = L.mapboxGL({
accessToken: 'ezree',
style: style
});
context._ready = true;
context.fire('ready', {}, true);
}
}, context);
} else {
throw new Error('Unable to fetch vector tile style metadata');
}
}, context);
}