Move attribution option and getAttribution to L.Layer (#5070)

Close #5051.
This commit is contained in:
Per Liedman 2016-11-03 09:32:56 +01:00 committed by Iván Sánchez Ortega
parent 9d91ab06ff
commit 957659fcd0
5 changed files with 15 additions and 22 deletions

View File

@ -35,7 +35,8 @@
var overlay = new L.ImageOverlay("https://www.lib.utexas.edu/maps/historical/newark_nj_1922.jpg", bounds, { var overlay = new L.ImageOverlay("https://www.lib.utexas.edu/maps/historical/newark_nj_1922.jpg", bounds, {
opacity: 0.5, opacity: 0.5,
interactive: true interactive: true,
attribution: '© A.B.B Corp.'
}); });
map.addLayer(overlay); map.addLayer(overlay);

View File

@ -136,10 +136,10 @@
geojson = L.geoJson(statesData, { geojson = L.geoJson(statesData, {
style: style, style: style,
onEachFeature: onEachFeature onEachFeature: onEachFeature,
attribution: 'Population data &copy; <a href="http://census.gov/">US Census Bureau</a>'
}); });
geojson.getAttribution = function() { return 'Population data &copy; <a href="http://census.gov/">US Census Bureau</a>' };
geojson.addTo(map); geojson.addTo(map);

View File

@ -31,10 +31,6 @@ L.ImageOverlay = L.Layer.extend({
// If `true`, the image overlay will emit [mouse events](#interactive-layer) when clicked or hovered. // If `true`, the image overlay will emit [mouse events](#interactive-layer) when clicked or hovered.
interactive: false, interactive: false,
// @option attribution: String = null
// An optional string containing HTML to be shown on the `Attribution control`
attribution: null,
// @option crossOrigin: Boolean = false // @option crossOrigin: Boolean = false
// If true, the image will have its crossOrigin attribute set to ''. This is needed if you want to access image pixel data. // If true, the image will have its crossOrigin attribute set to ''. This is needed if you want to access image pixel data.
crossOrigin: false crossOrigin: false
@ -128,10 +124,6 @@ L.ImageOverlay = L.Layer.extend({
return this; return this;
}, },
getAttribution: function () {
return this.options.attribution;
},
getEvents: function () { getEvents: function () {
var events = { var events = {
zoom: this._reset, zoom: this._reset,

View File

@ -31,7 +31,11 @@ L.Layer = L.Evented.extend({
// @option pane: String = 'overlayPane' // @option pane: String = 'overlayPane'
// By default the layer will be added to the map's [overlay pane](#map-overlaypane). Overriding this option will cause the layer to be placed on another pane by default. // By default the layer will be added to the map's [overlay pane](#map-overlaypane). Overriding this option will cause the layer to be placed on another pane by default.
pane: 'overlayPane', pane: 'overlayPane',
nonBubblingEvents: [] // Array of events that should not be bubbled to DOM parents (like the map) nonBubblingEvents: [], // Array of events that should not be bubbled to DOM parents (like the map),
// @option attribution: String = null
// String to be shown in the attribution control, describes the layer data, e.g. "© Mapbox".
attribution: null,
}, },
/* @section /* @section
@ -76,6 +80,12 @@ L.Layer = L.Evented.extend({
return this; return this;
}, },
// @method getAttribution: String
// Used by the `attribution control`, returns the [attribution option](#gridlayer-attribution).
getAttribution: function () {
return this.options.attribution;
},
_layerAdd: function (e) { _layerAdd: function (e) {
var map = e.target; var map = e.target;

View File

@ -89,10 +89,6 @@ L.GridLayer = L.Layer.extend({
// Tiles will not update more than once every `updateInterval` milliseconds when panning. // Tiles will not update more than once every `updateInterval` milliseconds when panning.
updateInterval: 200, updateInterval: 200,
// @option attribution: String = null
// String to be shown in the attribution control, describes the layer data, e.g. "© Mapbox".
attribution: null,
// @option zIndex: Number = 1 // @option zIndex: Number = 1
// The explicit zIndex of the tile layer. // The explicit zIndex of the tile layer.
zIndex: 1, zIndex: 1,
@ -174,12 +170,6 @@ L.GridLayer = L.Layer.extend({
return this; return this;
}, },
// @method getAttribution: String
// Used by the `attribution control`, returns the [attribution option](#gridlayer-attribution).
getAttribution: function () {
return this.options.attribution;
},
// @method getContainer: HTMLElement // @method getContainer: HTMLElement
// Returns the HTML element that contains the tiles for this layer. // Returns the HTML element that contains the tiles for this layer.
getContainer: function () { getContainer: function () {