Skip to content

Commit

Permalink
Merge pull request #2 from ilsanchez/leaflet073
Browse files Browse the repository at this point in the history
Leaflet073
  • Loading branch information
ilsanchez authored Jun 19, 2019
2 parents a19912d + ab675f2 commit 582b63b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dist/leaflet.wms.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
{
"author": "Houston Engineering, Inc",
"contributors": [
{
"name": "ilsanchez",
"url": "https://github.com/ilsanchez"
}
],
"name": "leaflet.wms",
"version": "0.2.0",
"description": "A Leaflet plugin for working with Web Map services, providing: single-tile/untiled/nontiled layers, shared WMS sources, and GetFeatureInfo-powered identify",
"description": "A Leaflet plugin for working with Web Map services, providing: single-tile/untiled/nontiled layers, shared WMS sources, request headers injection, and GetFeatureInfo-powered identify",
"license": "MIT",
"homepage": "https://github.com/heigeo/leaflet.wms",
"bugs": {
Expand Down
19 changes: 19 additions & 0 deletions src/leaflet.wms.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@
return {};
}
},

setUrl: function(url) {
this._url = url;
this._overlay && this._overlay.setUrl(url);
},

setOpacity: function(opacity) {
this.options.opacity = opacity;
Expand Down Expand Up @@ -290,6 +295,12 @@

// Extends default TileLayer to overwrite createTile method in order to inject our request headers
wms.TileLayer = L.TileLayer.WMS.extend({
options: {
crs: null,
uppercase: false,
headers: null,
getAjaxHeaders: null
},
createTile: function(coords, done) {
var _done = function(response) {
img.src = URL.createObjectURL(response);
Expand All @@ -298,6 +309,9 @@
var url = this.getTileUrl(coords);
var img = document.createElement('img');
ajax(url, _done, this.options, 'blob');
L.DomEvent.on(img, 'load', L.Util.bind(this._tileOnLoad, this, done, img));
L.DomEvent.on(img, 'error', L.Util.bind(this._tileOnError, this, done, img));
return img;
}
});

Expand Down Expand Up @@ -381,6 +395,11 @@
L.extend(this.wmsParams, params);
this.update();
},

setUrl: function(url) {
this._url = url;
this.update();
},

getAttribution: function() {
return this.options.attribution;
Expand Down

0 comments on commit 582b63b

Please sign in to comment.