Add OpenStreetMap options
This commit is contained in:
@@ -150,6 +150,12 @@
|
|||||||
@exportObjectLiteralProperty ol.source.DebugTileSourceOptions.projection ol.ProjectionLike
|
@exportObjectLiteralProperty ol.source.DebugTileSourceOptions.projection ol.ProjectionLike
|
||||||
@exportObjectLiteralProperty ol.source.DebugTileSourceOptions.tileGrid ol.tilegrid.TileGrid|undefined
|
@exportObjectLiteralProperty ol.source.DebugTileSourceOptions.tileGrid ol.tilegrid.TileGrid|undefined
|
||||||
|
|
||||||
|
@exportObjectLiteral ol.source.OpenStreetMapOptions
|
||||||
|
@exportObjectLiteralProperty ol.source.OpenStreetMapOptions.attribution ol.Attribution|undefined
|
||||||
|
@exportObjectLiteralProperty ol.source.OpenStreetMapOptions.attributions Array.<ol.Attribution>|undefined
|
||||||
|
@exportObjectLiteralProperty ol.source.OpenStreetMapOptions.maxZoom number|undefined
|
||||||
|
@exportObjectLiteralProperty ol.source.OpenStreetMapOptions.url string|undefined
|
||||||
|
|
||||||
@exportObjectLiteral ol.source.SingleImageWMSOptions
|
@exportObjectLiteral ol.source.SingleImageWMSOptions
|
||||||
@exportObjectLiteralProperty ol.source.SingleImageWMSOptions.attributions Array.<ol.Attribution>|undefined
|
@exportObjectLiteralProperty ol.source.SingleImageWMSOptions.attributions Array.<ol.Attribution>|undefined
|
||||||
@exportObjectLiteralProperty ol.source.SingleImageWMSOptions.crossOrigin null|string|undefined
|
@exportObjectLiteralProperty ol.source.SingleImageWMSOptions.crossOrigin null|string|undefined
|
||||||
|
|||||||
@@ -8,20 +8,39 @@ goog.require('ol.source.XYZ');
|
|||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.source.XYZ}
|
* @extends {ol.source.XYZ}
|
||||||
|
* @param {ol.source.OpenStreetMapOptions=} opt_options Open Street Map options.
|
||||||
*/
|
*/
|
||||||
ol.source.OpenStreetMap = function() {
|
ol.source.OpenStreetMap = function(opt_options) {
|
||||||
|
|
||||||
var attribution = new ol.Attribution(
|
var options = goog.isDef(opt_options) ? opt_options : {};
|
||||||
'© <a href="http://www.openstreetmap.org">OpenStreetMap</a> ' +
|
|
||||||
'contributors, ' +
|
var attributions;
|
||||||
'<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC BY-SA</a>');
|
if (goog.isDef(options.attributions)) {
|
||||||
|
attributions = options.attributions;
|
||||||
|
} else if (goog.isDef(options.attribution)) {
|
||||||
|
attributions = [options.attribution];
|
||||||
|
} else {
|
||||||
|
attributions = [
|
||||||
|
new ol.Attribution(
|
||||||
|
'© <a href="http://www.openstreetmap.org">OpenStreetMap</a> ' +
|
||||||
|
'contributors, ' +
|
||||||
|
'<a href="http://creativecommons.org/licenses/by-sa/2.0/"> ' +
|
||||||
|
'CC BY-SA' +
|
||||||
|
'</a>')
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
var maxZoom = goog.isDef(options.maxZoom) ? options.maxZoom : 18;
|
||||||
|
|
||||||
|
var url = goog.isDef(options.url) ?
|
||||||
|
options.url : 'http://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png';
|
||||||
|
|
||||||
goog.base(this, {
|
goog.base(this, {
|
||||||
attributions: [attribution],
|
attributions: attributions,
|
||||||
crossOrigin: 'anonymous',
|
crossOrigin: 'anonymous',
|
||||||
opaque: true,
|
opaque: true,
|
||||||
maxZoom: 18,
|
maxZoom: maxZoom,
|
||||||
url: 'http://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png'
|
url: url
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user