From 6147abd7cd1046dac3a4ef1f2336571cdd343d41 Mon Sep 17 00:00:00 2001 From: Kizito007 Date: Wed, 23 Oct 2024 16:07:43 +0100 Subject: [PATCH 1/5] fix: api key console error --- src/MaplibreGLLayer.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/MaplibreGLLayer.js b/src/MaplibreGLLayer.js index 096ccf0..457ec5c 100644 --- a/src/MaplibreGLLayer.js +++ b/src/MaplibreGLLayer.js @@ -168,6 +168,13 @@ export var MaplibreGLJSLayer = Layer.extend({ this._glMap = new maplibregl.Map(options); + // Listen for style data error (401 Unauthorized) + this._glMap.on('error', function (error) { + if (error.error && error.error.status === 401) { + console.warn('Invalid API key. Please check your ArcGIS API key.'); + } + }); + // Fire event for Maplibre "styledata" event. this._glMap.once( 'styledata', @@ -322,6 +329,6 @@ export var MaplibreGLJSLayer = Layer.extend({ } }); -export function maplibreGLJSLayer (options) { +export function maplibreGLJSLayer(options) { return new MaplibreGLJSLayer(options); } From 54904b45079cff08546f0e3093ae2a6a4f8a2436 Mon Sep 17 00:00:00 2001 From: Kizito007 Date: Wed, 23 Oct 2024 16:31:20 +0100 Subject: [PATCH 2/5] fix: lint space --- src/MaplibreGLLayer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MaplibreGLLayer.js b/src/MaplibreGLLayer.js index 457ec5c..635a527 100644 --- a/src/MaplibreGLLayer.js +++ b/src/MaplibreGLLayer.js @@ -329,6 +329,6 @@ export var MaplibreGLJSLayer = Layer.extend({ } }); -export function maplibreGLJSLayer(options) { +export function maplibreGLJSLayer (options) { return new MaplibreGLJSLayer(options); } From 9f1f5858302cac7a6d0f14fc2215ba91cfe0e8fa Mon Sep 17 00:00:00 2001 From: Kizito007 Date: Tue, 29 Oct 2024 17:58:31 +0100 Subject: [PATCH 3/5] fix: error warnings --- src/VectorBasemapLayer.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/VectorBasemapLayer.js b/src/VectorBasemapLayer.js index cb3f518..afe84d8 100644 --- a/src/VectorBasemapLayer.js +++ b/src/VectorBasemapLayer.js @@ -65,6 +65,19 @@ export var VectorBasemapLayer = VectorTileLayer.extend({ } else { styleUrl = getBasemapStyleUrl(this.options.key, this.options.apikey); } + // show error warning on successful response + fetch(styleUrl) + .then(response => { + return response.json(); + }) + .then(styleData => { + if (styleData.error) { + console.warn('Error:', styleData.error.message); + } + }) + .catch(err => { + console.warn('Error:', err.message); + }); this._createMaplibreLayer(styleUrl); }, From d8b33531d5395cd0eeb81fe2b1ea25b6e957bba5 Mon Sep 17 00:00:00 2001 From: Kizito Nwaka Date: Wed, 18 Dec 2024 13:46:42 +0100 Subject: [PATCH 4/5] Update src/MaplibreGLLayer.js Co-authored-by: Patrick Arlt --- src/MaplibreGLLayer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MaplibreGLLayer.js b/src/MaplibreGLLayer.js index 635a527..713a675 100644 --- a/src/MaplibreGLLayer.js +++ b/src/MaplibreGLLayer.js @@ -171,7 +171,7 @@ export var MaplibreGLJSLayer = Layer.extend({ // Listen for style data error (401 Unauthorized) this._glMap.on('error', function (error) { if (error.error && error.error.status === 401) { - console.warn('Invalid API key. Please check your ArcGIS API key.'); + console.warn('Invalid or expired API key. Please check that API key is not expired and has the basemaps privilege assigned.'); } }); From becb9b961c43162689593f3362ecd4af323ffa31 Mon Sep 17 00:00:00 2001 From: Kizito007 Date: Wed, 18 Dec 2024 20:08:35 +0100 Subject: [PATCH 5/5] fix: error message on v1 response --- src/VectorBasemapLayer.js | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/VectorBasemapLayer.js b/src/VectorBasemapLayer.js index afe84d8..6726c31 100644 --- a/src/VectorBasemapLayer.js +++ b/src/VectorBasemapLayer.js @@ -65,19 +65,21 @@ export var VectorBasemapLayer = VectorTileLayer.extend({ } else { styleUrl = getBasemapStyleUrl(this.options.key, this.options.apikey); } - // show error warning on successful response - fetch(styleUrl) - .then(response => { - return response.json(); - }) - .then(styleData => { - if (styleData.error) { - console.warn('Error:', styleData.error.message); - } - }) - .catch(err => { - console.warn('Error:', err.message); - }); + // show error warning on successful response for previous version(1) + if (this.options.version && this.options.version === 1) { + fetch(styleUrl) + .then(response => { + return response.json(); + }) + .then(styleData => { + if (styleData.error) { + console.warn('Error:', styleData.error.message); + } + }) + .catch(error => { + console.warn('Error:', error.message); + }); + } this._createMaplibreLayer(styleUrl); },