How to use the esri-leaflet.request function in esri-leaflet

To help you get started, we’ve selected a few esri-leaflet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Esri / esri-leaflet-vector / src / Layer.js View on Github external
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;
                }
github Esri / esri-leaflet-vector / src / Layer.js View on Github external
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
                    });
github Esri / esri-leaflet-vector / src / Layer.js View on Github external
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 {
github Esri / esri-leaflet-vector / src / Util.js View on Github external
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');
    }
github Esri / esri-leaflet-vector / src / Util.js View on Github external
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);
}