Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MapboxImageryProvider: high-DPI (@2x) support #3899

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion Source/Scene/MapboxImageryProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ define([
* @param {String} [options.url='https://api.mapbox.com/v4/'] The Mapbox server url.
* @param {String} options.mapId The Mapbox Map ID.
* @param {String} [options.accessToken] The public access token for the imagery.
* @param {Boolean} [options.retina] Whether or not to request high DPI images.
* @param {String} [options.format='png'] The format of the image request.
* @param {Object} [options.proxy] A proxy to use for requests. This object is expected to have a getURL function which returns the proxied URL.
* @param {Ellipsoid} [options.ellipsoid] The ellipsoid. If not specified, the WGS84 ellipsoid is used.
Expand Down Expand Up @@ -68,11 +69,19 @@ define([
var format = defaultValue(options.format, 'png');
this._format = format.replace('.', '');

if (defined(options.retina)) {
this._retina = options.retina;
} else {
this._retina = false;
}

var retinaIdentifier = this._retina ? '@2x' : '';

var templateUrl = url;
if (!trailingSlashRegex.test(url)) {
templateUrl += '/';
}
templateUrl += mapId + '/{z}/{x}/{y}.' + this._format;
templateUrl += mapId + '/{z}/{x}/{y}' + retinaIdentifier + '.' + this._format;
if (defined(this._accessToken)) {
templateUrl += '?access_token=' + this._accessToken;
}
Expand Down Expand Up @@ -122,6 +131,19 @@ define([
}
},

/**
* Gets a value indicating whether or not the provider will retrieve
* high DPI (Retina) images.
* @memberof MapboxImageryProvider.prototype
* @type {Boolean}
* @readonly
*/
retina : {
get : function() {
return this._retina;
}
},

/**
* Gets a promise that resolves to true when the provider is ready for use.
* @memberof MapboxImageryProvider.prototype
Expand Down