function loadImage(tile, callback) {
            if (this.downloading >= this.config.imageLoaderLimit) {
                tile.loading = false;
            }
            var that = this;
            var url = tile.url;

            this.downloading++;
            var timeout;
            var image = new Image();

            function catchedCallback() {
                that.downloading--;
                if (typeof callback === 'function') {
                    try {
                        callback();
                    } catch (error) {
                        console.error('Error while executing ' + url + ' callback.', error);
                    }
                }
            }

            function getFinishFunction(success) {
                return function () {
                    if (timeout) {
                        clearTimeout(timeout);
                    }
                    image.onload = image.onabort = image.onerror = null;
                    if (!success) { // we failed or timeout was reached; cancel loading
                        console.error('Image failed to load.', image.src);
                        if (that.config.dropImageLoadingOnTimeout) {
                            // Set src to a blank GIF.
                            image.src = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
                        }
                    }
                    tile.loading = false;
                    tile.loaded = success;
                    tile.image = image;

                    // Call on a timeout to ensure asynchronous behavior.
                    setTimeout(catchedCallback);
                };
            }

            image.onload = getFinishFunction(true);
            image.onabort = image.onerror = getFinishFunction(false);

            // Consider it a failure if the image times out.
            timeout = setTimeout(getFinishFunction(false), this.config.imageLoaderTimeout);
            image.src = url;

            tile.loading = true;
        }
/**
         * Loads an image.
         *
         * @param {string} src URL to the image to be loaded
         * @param {function} [callback] Callback function to be executed after image is loaded
         */
Loads an image.
@param {string} src URL to the image to be loaded
@param {function} [callback] Callback function to be executed after image is loaded
Loads an image . @param { string } src URL to the image to be loaded @param { function } [ callback ] Callback function to be executed after image is loaded
function loadImage(tile, callback) {
            if (this.downloading >= this.config.imageLoaderLimit) {
                tile.loading = false;
            }
            var that = this;
            var url = tile.url;
            this.downloading++;
            var timeout;
            var image = new Image();
            function catchedCallback() {
                that.downloading--;
                if (typeof callback === 'function') {
                    try {
                        callback();
                    } catch (error) {
                        console.error('Error while executing ' + url + ' callback.', error);
                    }
                }
            }
            function getFinishFunction(success) {
                return function () {
                    if (timeout) {
                        clearTimeout(timeout);
                    }
                    image.onload = image.onabort = image.onerror = null;
                    if (!success) { 
                        console.error('Image failed to load.', image.src);
                        if (that.config.dropImageLoadingOnTimeout) {
                            image.src = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
                        }
                    }
                    tile.loading = false;
                    tile.loaded = success;
                    tile.image = image;
                    setTimeout(catchedCallback);
                };
            }
            image.onload = getFinishFunction(true);
            image.onabort = image.onerror = getFinishFunction(false);
            timeout = setTimeout(getFinishFunction(false), this.config.imageLoaderTimeout);
            image.src = url;
            tile.loading = true;
        }
function loadImage ( tile , callback ) { if ( this . downloading >= this . config . imageLoaderLimit ) { tile . loading = false ; } var that = this ; var url = tile . url ; this . downloading ++ ; var timeout ; var image = new Image ( ) ; function catchedCallback ( ) { that . downloading -- ; if ( typeof callback === 'function' ) { try { callback ( ) ; } catch ( error ) { console . error ( 'Error while executing ' + url + ' callback.' , error ) ; } } } function getFinishFunction ( success ) { return function ( ) { if ( timeout ) { clearTimeout ( timeout ) ; } image . onload = image . onabort = image . onerror = null ; if ( ! success ) { console . error ( 'Image failed to load.' , image . src ) ; if ( that . config . dropImageLoadingOnTimeout ) { image . src = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==' ; } } tile . loading = false ; tile . loaded = success ; tile . image = image ; setTimeout ( catchedCallback ) ; } ; } image . onload = getFinishFunction ( true ) ; image . onabort = image . onerror = getFinishFunction ( false ) ; timeout = setTimeout ( getFinishFunction ( false ) , this . config . imageLoaderTimeout ) ; image . src = url ; tile . loading = true ; }
Loads an image.
Loads an image .
// we failed or timeout was reached; cancel loading // Set src to a blank GIF. // Call on a timeout to ensure asynchronous behavior. // Consider it a failure if the image times out.