Merge pull request #5955 from bartvde/bing-getters
Add getters to BingMaps source for api key and imagerySet
This commit is contained in:
@@ -46,9 +46,21 @@ ol.source.BingMaps = function(options) {
|
||||
*/
|
||||
this.maxZoom_ = options.maxZoom !== undefined ? options.maxZoom : -1;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {string}
|
||||
*/
|
||||
this.apiKey_ = options.key;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {string}
|
||||
*/
|
||||
this.imagerySet_ = options.imagerySet;
|
||||
|
||||
var url = 'https://dev.virtualearth.net/REST/v1/Imagery/Metadata/' +
|
||||
options.imagerySet +
|
||||
'?uriScheme=https&include=ImageryProviders&key=' + options.key;
|
||||
this.imagerySet_ +
|
||||
'?uriScheme=https&include=ImageryProviders&key=' + this.apiKey_;
|
||||
|
||||
ol.net.jsonp(url, this.handleImageryMetadataResponse.bind(this), undefined,
|
||||
'jsonp');
|
||||
@@ -71,6 +83,28 @@ ol.source.BingMaps.TOS_ATTRIBUTION = new ol.Attribution({
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Get the api key used for this source.
|
||||
*
|
||||
* @return {string} The api key.
|
||||
* @api
|
||||
*/
|
||||
ol.source.BingMaps.prototype.getApiKey = function() {
|
||||
return this.apiKey_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the imagery set associated with this source.
|
||||
*
|
||||
* @return {string} The imagery set.
|
||||
* @api
|
||||
*/
|
||||
ol.source.BingMaps.prototype.getImagerySet = function() {
|
||||
return this.imagerySet_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {BingMapsImageryMetadataResponse} response Response.
|
||||
*/
|
||||
|
||||
@@ -37,6 +37,14 @@ describe('ol.source.BingMaps', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('getImagerySet works correctly', function() {
|
||||
expect(source.getImagerySet()).to.equal('AerialWithLabels');
|
||||
});
|
||||
|
||||
it('getApiKey works correctly', function() {
|
||||
expect(source.getApiKey()).to.equal('');
|
||||
});
|
||||
|
||||
it('returns the expected URL', function() {
|
||||
|
||||
var coordinate = [829330.2064098881, 5933916.615134273];
|
||||
|
||||
Reference in New Issue
Block a user