use a single ol.source.MapQuest and use a const for the tile attribution
This commit is contained in:
@@ -4,30 +4,28 @@ goog.require('ol.View2D');
|
|||||||
goog.require('ol.layer.Group');
|
goog.require('ol.layer.Group');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
goog.require('ol.proj');
|
goog.require('ol.proj');
|
||||||
goog.require('ol.source.MapQuestHybrid');
|
goog.require('ol.source.MapQuest');
|
||||||
goog.require('ol.source.MapQuestOSM');
|
|
||||||
goog.require('ol.source.MapQuestOpenAerial');
|
|
||||||
|
|
||||||
|
|
||||||
var layers = [
|
var layers = [
|
||||||
new ol.layer.Tile({
|
new ol.layer.Tile({
|
||||||
style: 'Road',
|
style: 'Road',
|
||||||
source: new ol.source.MapQuestOSM()
|
source: new ol.source.MapQuest({layer: 'osm'})
|
||||||
}),
|
}),
|
||||||
new ol.layer.Tile({
|
new ol.layer.Tile({
|
||||||
style: 'Aerial',
|
style: 'Aerial',
|
||||||
visible: false,
|
visible: false,
|
||||||
source: new ol.source.MapQuestOpenAerial()
|
source: new ol.source.MapQuest({layer: 'sat'})
|
||||||
}),
|
}),
|
||||||
new ol.layer.Group({
|
new ol.layer.Group({
|
||||||
style: 'AerialWithLabels',
|
style: 'AerialWithLabels',
|
||||||
visible: false,
|
visible: false,
|
||||||
layers: [
|
layers: [
|
||||||
new ol.layer.Tile({
|
new ol.layer.Tile({
|
||||||
source: new ol.source.MapQuestOpenAerial()
|
source: new ol.source.MapQuest({layer: 'sat'})
|
||||||
}),
|
}),
|
||||||
new ol.layer.Tile({
|
new ol.layer.Tile({
|
||||||
source: new ol.source.MapQuestHybrid()
|
source: new ol.source.MapQuest({layer: 'hyb'})
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -651,6 +651,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} olx.source.MapQuestOptions
|
* @typedef {Object} olx.source.MapQuestOptions
|
||||||
|
* @property {string} layer Layer.
|
||||||
* @property {ol.TileLoadFunctionType|undefined} tileLoadFunction Optional
|
* @property {ol.TileLoadFunctionType|undefined} tileLoadFunction Optional
|
||||||
* function to load a tile given a URL.
|
* function to load a tile given a URL.
|
||||||
* @todo stability experimental
|
* @todo stability experimental
|
||||||
|
|||||||
@@ -1,3 +1 @@
|
|||||||
@exportSymbol ol.source.MapQuestOSM
|
@exportSymbol ol.source.MapQuest
|
||||||
@exportSymbol ol.source.MapQuestOpenAerial
|
|
||||||
@exportSymbol ol.source.MapQuestHybrid
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
goog.provide('ol.source.MapQuestHybrid');
|
goog.provide('ol.source.MapQuest');
|
||||||
goog.provide('ol.source.MapQuestOSM');
|
|
||||||
goog.provide('ol.source.MapQuestOpenAerial');
|
|
||||||
|
|
||||||
|
goog.require('goog.asserts');
|
||||||
goog.require('ol.Attribution');
|
goog.require('ol.Attribution');
|
||||||
goog.require('ol.source.OSM');
|
goog.require('ol.source.OSM');
|
||||||
goog.require('ol.source.XYZ');
|
goog.require('ol.source.XYZ');
|
||||||
@@ -14,96 +13,66 @@ goog.require('ol.source.XYZ');
|
|||||||
* @param {olx.source.MapQuestOptions=} opt_options MapQuest options.
|
* @param {olx.source.MapQuestOptions=} opt_options MapQuest options.
|
||||||
* @todo stability experimental
|
* @todo stability experimental
|
||||||
*/
|
*/
|
||||||
ol.source.MapQuestOSM = function(opt_options) {
|
ol.source.MapQuest = function(opt_options) {
|
||||||
|
|
||||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
var options = goog.isDef(opt_options) ? opt_options : {};
|
||||||
|
goog.asserts.assert(options.layer in ol.source.MapQuestConfig);
|
||||||
|
|
||||||
var attributions = [
|
var layerConfig = ol.source.MapQuestConfig[options.layer];
|
||||||
new ol.Attribution({
|
|
||||||
html: 'Tiles Courtesy of ' +
|
var url = 'http://otile{1-4}.mqcdn.com/tiles/1.0.0/' +
|
||||||
'<a href="http://www.mapquest.com/" target="_blank">MapQuest</a>'
|
options.layer + '/{z}/{x}/{y}.jpg';
|
||||||
}),
|
|
||||||
ol.source.OSM.DATA_ATTRIBUTION
|
|
||||||
];
|
|
||||||
|
|
||||||
goog.base(this, {
|
goog.base(this, {
|
||||||
attributions: attributions,
|
attributions: layerConfig.attributions,
|
||||||
crossOrigin: 'anonymous',
|
crossOrigin: 'anonymous',
|
||||||
logo: 'http://developer.mapquest.com/content/osm/mq_logo.png',
|
logo: 'http://developer.mapquest.com/content/osm/mq_logo.png',
|
||||||
|
maxZoom: layerConfig.maxZoom,
|
||||||
opaque: true,
|
opaque: true,
|
||||||
maxZoom: 28,
|
|
||||||
tileLoadFunction: options.tileLoadFunction,
|
tileLoadFunction: options.tileLoadFunction,
|
||||||
url: 'http://otile{1-4}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.jpg'
|
url: url
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.source.MapQuestOSM, ol.source.XYZ);
|
goog.inherits(ol.source.MapQuest, ol.source.XYZ);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @const
|
||||||
* @extends {ol.source.XYZ}
|
* @type {ol.Attribution}
|
||||||
* @param {olx.source.MapQuestOptions=} opt_options MapQuest options.
|
|
||||||
* @todo stability experimental
|
|
||||||
*/
|
*/
|
||||||
ol.source.MapQuestOpenAerial = function(opt_options) {
|
ol.source.MapQuest.TILE_ATTRIBUTION = new ol.Attribution({
|
||||||
|
|
||||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
|
||||||
|
|
||||||
var attributions = [
|
|
||||||
new ol.Attribution({
|
|
||||||
html: 'Tiles Courtesy of ' +
|
html: 'Tiles Courtesy of ' +
|
||||||
'<a href="http://www.mapquest.com/" target="_blank">MapQuest</a>'
|
'<a href="http://www.mapquest.com/" target="_blank">MapQuest</a>'
|
||||||
}),
|
});
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {Object.<string, {maxZoom: number, attributions: (Array.<ol.Attribution>)}>}
|
||||||
|
*/
|
||||||
|
ol.source.MapQuestConfig = {
|
||||||
|
'osm': {
|
||||||
|
maxZoom: 28,
|
||||||
|
attributions: [
|
||||||
|
ol.source.MapQuest.TILE_ATTRIBUTION,
|
||||||
|
ol.source.OSM.DATA_ATTRIBUTION
|
||||||
|
]
|
||||||
|
},
|
||||||
|
'sat': {
|
||||||
|
maxZoom: 18,
|
||||||
|
attributions: [
|
||||||
|
ol.source.MapQuest.TILE_ATTRIBUTION,
|
||||||
new ol.Attribution({
|
new ol.Attribution({
|
||||||
html: 'Portions Courtesy NASA/JPL-Caltech and ' +
|
html: 'Portions Courtesy NASA/JPL-Caltech and ' +
|
||||||
'U.S. Depart. of Agriculture, Farm Service Agency'
|
'U.S. Depart. of Agriculture, Farm Service Agency'
|
||||||
})
|
})
|
||||||
];
|
]
|
||||||
|
},
|
||||||
goog.base(this, {
|
'hyb': {
|
||||||
attributions: attributions,
|
|
||||||
crossOrigin: 'anonymous',
|
|
||||||
logo: 'http://developer.mapquest.com/content/osm/mq_logo.png',
|
|
||||||
maxZoom: 18,
|
maxZoom: 18,
|
||||||
opaque: true,
|
attributions: [
|
||||||
tileLoadFunction: options.tileLoadFunction,
|
ol.source.MapQuest.TILE_ATTRIBUTION,
|
||||||
url: 'http://oatile{1-4}.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.jpg'
|
|
||||||
});
|
|
||||||
|
|
||||||
};
|
|
||||||
goog.inherits(ol.source.MapQuestOpenAerial, ol.source.XYZ);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @extends {ol.source.XYZ}
|
|
||||||
* @param {olx.source.MapQuestOptions=} opt_options MapQuest options.
|
|
||||||
* @todo stability experimental
|
|
||||||
*/
|
|
||||||
ol.source.MapQuestHybrid = function(opt_options) {
|
|
||||||
|
|
||||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
|
||||||
|
|
||||||
var attributions = [
|
|
||||||
new ol.Attribution({
|
|
||||||
html: 'Tiles Courtesy of ' +
|
|
||||||
'<a href="http://www.mapquest.com/" target="_blank">MapQuest</a>'
|
|
||||||
}),
|
|
||||||
ol.source.OSM.DATA_ATTRIBUTION
|
ol.source.OSM.DATA_ATTRIBUTION
|
||||||
];
|
]
|
||||||
|
}
|
||||||
goog.base(this, {
|
|
||||||
attributions: attributions,
|
|
||||||
crossOrigin: 'anonymous',
|
|
||||||
logo: 'http://developer.mapquest.com/content/osm/mq_logo.png',
|
|
||||||
maxZoom: 18,
|
|
||||||
opaque: true,
|
|
||||||
tileLoadFunction: options.tileLoadFunction,
|
|
||||||
url: 'http://oatile{1-4}.mqcdn.com/tiles/1.0.0/hyb/{z}/{x}/{y}.jpg'
|
|
||||||
});
|
|
||||||
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.source.MapQuestHybrid, ol.source.XYZ);
|
|
||||||
|
|||||||
Reference in New Issue
Block a user