jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/384078 )
Change subject: Handle geoshape loading errors more gracefully ...................................................................... Handle geoshape loading errors more gracefully When a geoshape can’t be loaded, we should still draw a map with all the other layers. (Due to the way the overall promise currently works, we’ll only draw a map with all layers loaded before the first failing one, but that’s still better than nothing.) Change-Id: I219ac53e269bbf25e026eedba95c830c4b3f4fb6 --- M wikibase/queryService/ui/resultBrowser/CoordinateResultBrowser.js 1 file changed, 39 insertions(+), 33 deletions(-) Approvals: Jonas Kress (WMDE): Looks good to me, approved jenkins-bot: Verified diff --git a/wikibase/queryService/ui/resultBrowser/CoordinateResultBrowser.js b/wikibase/queryService/ui/resultBrowser/CoordinateResultBrowser.js index 04ddfd3..d7d4b95 100644 --- a/wikibase/queryService/ui/resultBrowser/CoordinateResultBrowser.js +++ b/wikibase/queryService/ui/resultBrowser/CoordinateResultBrowser.js @@ -138,11 +138,41 @@ */ SELF.prototype.draw = function( $element ) { var self = this, - container = $( '<div>' ).attr( 'id', 'map' ).height( '100vh' ); + container = $( '<div>' ).attr( 'id', 'map' ).height( '100vh' ), + interval; $element.html( container ); - this._createMarkerGroups().done( function() { + function clearProgress() { + clearInterval( interval ); + $( '#map-progress' ).remove(); + } + function updateProgress() { + if ( self._markerGroupsProgress > 0 && self._markerGroupsProgress < 1 ) { + var percent = ( 100 * self._markerGroupsProgress ).toFixed( 2 ), + message = self._i18n( + 'wdqs-result-map-progress', + 'Loading map data: $1%', + [ percent ] ); + container.html( + $( '<div>' ) + .attr( 'id', 'map-progress' ) + .css( { + position: 'relative', + top: '20%', + width: '100%', + textAlign: 'center' + } ) + .text( message ) + ); + } else if ( self._markerGroupsProgress >= 1 ) { + clearProgress(); + } + } + interval = setInterval( updateProgress, 200 ); + + function drawMap() { + clearProgress(); self._map = L.map( 'map', { center: [ 0, 0 ], maxZoom: 18, @@ -157,34 +187,9 @@ self._createMarkerZoomResize(); $element.html( container ); - } ); + } - var interval = setInterval( - function() { - if ( self._markerGroupsProgress > 0 && self._markerGroupsProgress < 1 ) { - var percent = ( 100 * self._markerGroupsProgress ).toFixed( 2 ), - message = self._i18n( - 'wdqs-result-map-progress', - 'Loading map data: $1%', - [ percent ] ); - container.html( - $( '<div>' ) - .attr( 'id', 'map-progress' ) - .css( { - position: 'relative', - top: '20%', - width: '100%', - textAlign: 'center' - } ) - .text( message ) - ); - } else if ( self._markerGroupsProgress === 1 ) { - clearInterval( interval ); - $( '#map-progress' ).remove(); - } - }, - 200 - ); + this._createMarkerGroups().done( drawMap ).fail( drawMap ); }; /** @@ -324,18 +329,19 @@ } ); } ); - return $.when.apply( $, promises ).done( function() { + function createMarkers() { if ( Object.keys( markers ).length === 0 ) { var marker = L.marker( [ 0, 0 ] ).bindPopup( 'Nothing found!' ).openPopup(); return { null: L.featureGroup( [marker] ) }; } + self._markerGroups = {}; $.each( markers, function( key ) { - markers[ key ] = L.featureGroup( markers[ key ] ); + self._markerGroups[ key ] = L.featureGroup( markers[ key ] ); } ); + } - self._markerGroups = markers; - } ); + return $.when.apply( $, promises ).done( createMarkers ).fail( createMarkers ); }; /** -- To view, visit https://gerrit.wikimedia.org/r/384078 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I219ac53e269bbf25e026eedba95c830c4b3f4fb6 Gerrit-PatchSet: 4 Gerrit-Project: wikidata/query/gui Gerrit-Branch: master Gerrit-Owner: Lucas Werkmeister (WMDE) <lucas.werkmeis...@wikimedia.de> Gerrit-Reviewer: Jonas Kress (WMDE) <jonas.kr...@wikimedia.de> Gerrit-Reviewer: Smalyshev <smalys...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits