Move attribution option and getAttribution to L.Layer (#5070)
Close #5051.
This commit is contained in:
parent
9d91ab06ff
commit
957659fcd0
@ -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);
|
||||||
|
|
||||||
|
@ -136,10 +136,10 @@
|
|||||||
|
|
||||||
geojson = L.geoJson(statesData, {
|
geojson = L.geoJson(statesData, {
|
||||||
style: style,
|
style: style,
|
||||||
onEachFeature: onEachFeature
|
onEachFeature: onEachFeature,
|
||||||
|
attribution: 'Population data © <a href="http://census.gov/">US Census Bureau</a>'
|
||||||
});
|
});
|
||||||
|
|
||||||
geojson.getAttribution = function() { return 'Population data © <a href="http://census.gov/">US Census Bureau</a>' };
|
|
||||||
geojson.addTo(map);
|
geojson.addTo(map);
|
||||||
|
|
||||||
|
|
||||||
|
@ -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,
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
@ -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 () {
|
||||||
|
Loading…
Reference in New Issue
Block a user