Skip to content

Commit

Permalink
revised fix for owmloading.gif (#508)
Browse files Browse the repository at this point in the history
* revised fix for owmloading.gif

* fixed!

* bump to 2.4.3
  • Loading branch information
jywarren authored Feb 17, 2021
1 parent 4a7efa1 commit 42db74c
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 10 deletions.
20 changes: 20 additions & 0 deletions cypress/integration/owm.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
describe('OpenWeatherMap layer', function() {
it('adds markers on click', function() {
cy.openWindow('/example/index.html#lat=41.6283&lon=-91.7235&zoom=10&layers=Standard')
cy.wait(300)
cy.window().then((win) => {
cy.get('.leaflet-tile-pane').children().should('have.length', 1)
cy.get('#map-city label').click({ force: true })
cy.get('.leaflet-tile-pane').children().should('have.length', 2)
cy.get('.img')
})
})

it('loads correct owmloading.gif with config option set', function() {
cy.openWindow('/example/oneLinerCodeExample.html')
cy.wait(300)
cy.window().then((win) => {
expect(LEL.overlayMaps.current.options.imageLoadingUrl).to.equal('https://raw.githubusercontent.com/buche/leaflet-openweathermap/master/owmloading.gif')
})
})
});
12 changes: 8 additions & 4 deletions dist/LeafletEnvironmentalLayers.js
Original file line number Diff line number Diff line change
Expand Up @@ -25999,7 +25999,11 @@ L.LayerGroup.environmentalLayers = L.LayerGroup.extend(
}
if (layer === 'city') {
layer = 'current';
obj = {intervall: 15, minZoom: 3};
obj = {
intervall: 15,
minZoom: 3,
imageLoadingUrl: this.options.imageLoadingUrl
};
this.overlayMaps[layer] = window['L']['OWM'][layer](obj).on('owmloadingend', function() {
this.onError(layer, true);
})
Expand Down Expand Up @@ -27816,6 +27820,7 @@ L.OWM = L.TileLayer.extend({
L.OWM.Wind = L.OWM.extend({
_owmLayerName: 'wind',
});
/////////
L.OWM.wind = function(options) {
var layer = new L.OWM.Wind(options);
if (layer.options.legendImagePath == null) {
Expand Down Expand Up @@ -27900,7 +27905,7 @@ L.OWM.Current = L.Layer.extend({
minZoom: 7,
interval: 0, // interval for rereading city data in minutes
progressControl: true, // available: true, false
imageLoadingUrl: 'owmloading.gif', // URL of loading image relative to HTML document
imageLoadingUrl: 'images/owmloading.gif', // URL of loading image relative to HTML document
imageLoadingBgUrl: null, // URL of background image for progress control
temperatureUnit: 'C', // available: 'K' (Kelvin), 'C' (Celsius), 'F' (Fahrenheit)
temperatureDigits: 1,
Expand Down Expand Up @@ -27932,6 +27937,7 @@ L.OWM.Current = L.Layer.extend({
},

initialize: function(options) {
options.imageLoadingUrl = options.imageLoadingUrl || this.options.imageLoadingUrl;
L.setOptions(this, options);
this._layer = L.layerGroup();
this._timeoutId = null;
Expand Down Expand Up @@ -29184,8 +29190,6 @@ L.OWM.Utils = {
},
};



},{}],17:[function(require,module,exports){
L.LayerGroup.OSMLandfillMineQuarryLayer = L.LayerGroup.extend(

Expand Down
8 changes: 5 additions & 3 deletions example/oneLinerCodeExample.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,18 @@
}).setView([43, -83], 3);
map.options.minZoom = 3;

L.LayerGroup.EnvironmentalLayers({
var LEL = L.LayerGroup.EnvironmentalLayers({
// simpleLayerControl: true,
addLayersToMap: true,
include: ['skytruth', 'odorreport', 'asian', 'clouds', 'eonetFiresLayer', 'Unearthing', 'PLpeople'],
include: ['skytruth', 'odorreport', 'asian', 'wind', 'city', 'eonetFiresLayer', 'Unearthing', 'PLpeople'],
// exclude: ['mapknitter', 'clouds'],
// display: ['eonetFiresLayer'],
hash: true,
embed: true,
imageLoadingUrl: "https://raw.githubusercontent.com/buche/leaflet-openweathermap/master/owmloading.gif",
// hostname: 'domain name goes here'
}).addTo(map);
});
LEL.addTo(map);

</script>

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "leaflet-environmental-layers",
"version": "2.4.2",
"version": "2.4.3",
"description": "",
"main": "index.js",
"directories": {
Expand Down
6 changes: 5 additions & 1 deletion src/AllLayers.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,11 @@ L.LayerGroup.environmentalLayers = L.LayerGroup.extend(
}
if (layer === 'city') {
layer = 'current';
obj = {intervall: 15, minZoom: 3};
obj = {
intervall: 15,
minZoom: 3,
imageLoadingUrl: this.options.imageLoadingUrl
};
this.overlayMaps[layer] = window['L']['OWM'][layer](obj).on('owmloadingend', function() {
this.onError(layer, true);
})
Expand Down
3 changes: 2 additions & 1 deletion src/openWeatherMapLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ L.OWM = L.TileLayer.extend({
L.OWM.Wind = L.OWM.extend({
_owmLayerName: 'wind',
});
/////////
L.OWM.wind = function(options) {
var layer = new L.OWM.Wind(options);
if (layer.options.legendImagePath == null) {
Expand Down Expand Up @@ -255,7 +256,7 @@ L.OWM.Current = L.Layer.extend({
},

initialize: function(options) {
options.imageLoadingUrl = this.options.imageLoadingUrl || "owmloading.gif";
options.imageLoadingUrl = options.imageLoadingUrl || this.options.imageLoadingUrl;
L.setOptions(this, options);
this._layer = L.layerGroup();
this._timeoutId = null;
Expand Down

0 comments on commit 42db74c

Please sign in to comment.