From 42db74ca5104ead4569ee88f3c96a0941988a7b5 Mon Sep 17 00:00:00 2001 From: Jeffrey Warren Date: Wed, 17 Feb 2021 18:23:31 -0500 Subject: [PATCH] revised fix for owmloading.gif (#508) * revised fix for owmloading.gif * fixed! * bump to 2.4.3 --- cypress/integration/owm.spec.js | 20 ++++++++++++++++++++ dist/LeafletEnvironmentalLayers.js | 12 ++++++++---- example/oneLinerCodeExample.html | 8 +++++--- package.json | 2 +- src/AllLayers.js | 6 +++++- src/openWeatherMapLayer.js | 3 ++- 6 files changed, 41 insertions(+), 10 deletions(-) create mode 100644 cypress/integration/owm.spec.js diff --git a/cypress/integration/owm.spec.js b/cypress/integration/owm.spec.js new file mode 100644 index 000000000..79a6d5008 --- /dev/null +++ b/cypress/integration/owm.spec.js @@ -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') + }) + }) +}); \ No newline at end of file diff --git a/dist/LeafletEnvironmentalLayers.js b/dist/LeafletEnvironmentalLayers.js index ea8750de0..6fcf97439 100644 --- a/dist/LeafletEnvironmentalLayers.js +++ b/dist/LeafletEnvironmentalLayers.js @@ -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); }) @@ -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) { @@ -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, @@ -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; @@ -29184,8 +29190,6 @@ L.OWM.Utils = { }, }; - - },{}],17:[function(require,module,exports){ L.LayerGroup.OSMLandfillMineQuarryLayer = L.LayerGroup.extend( diff --git a/example/oneLinerCodeExample.html b/example/oneLinerCodeExample.html index dd6973d2e..8825fbe2c 100644 --- a/example/oneLinerCodeExample.html +++ b/example/oneLinerCodeExample.html @@ -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); diff --git a/package.json b/package.json index 023c4f521..012f79172 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "leaflet-environmental-layers", - "version": "2.4.2", + "version": "2.4.3", "description": "", "main": "index.js", "directories": { diff --git a/src/AllLayers.js b/src/AllLayers.js index 6416365fc..048991a3c 100644 --- a/src/AllLayers.js +++ b/src/AllLayers.js @@ -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); }) diff --git a/src/openWeatherMapLayer.js b/src/openWeatherMapLayer.js index ef6886796..8aba267d2 100644 --- a/src/openWeatherMapLayer.js +++ b/src/openWeatherMapLayer.js @@ -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) { @@ -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;