Skip to content

Commit

Permalink
Add opacity and zIndex property for TileLayer
Browse files Browse the repository at this point in the history
Change TileLayer params name to options to be more consisitent with Leaflet and the rest of Vue2Leaflet
  • Loading branch information
KoRiGaN committed Oct 2, 2017
1 parent 551f909 commit a34abe3
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/components/TileLayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,16 @@ const props = {
type: String,
custom: true
},
params: {
opacity: {
type: Number,
custom: false,
default: 1.0
},
zIndex: {
type: Number,
default: 1
},
options: {
type: Object,
default: function() {
return {};
Expand All @@ -42,9 +51,14 @@ const props = {
export default {
props: props,
mounted() {
if (this.attribution) this.params['attribution'] = this.attribution;
if (this.token) this.params['token'] = this.token;
this.mapObject = L.tileLayer(this.url, this.params);
const otherPropertytoInitialize = [ "attribution", "token", "opacity", "zIndex" ];
for (var i = 0; i < otherPropertytoInitialize.length; i++) {
const propName = otherPropertytoInitialize[i];
if(this[propName]) {
options[propName] = this[propName];
}
}
this.mapObject = L.tileLayer(this.url, this.options);
eventsBinder(this, this.mapObject, events);
propsBinder(this, this.mapObject, props);
},
Expand All @@ -62,7 +76,7 @@ export default {
this.attributionControl.addAttribution(val);
},
setToken(val) {
this.params.token = val;
this.options.token = val;
}
}
};
Expand Down

0 comments on commit a34abe3

Please sign in to comment.