Skip to content

Commit 07a477c

Browse files
authored
adjust attributions in GoogleMapsTilesCredits (#497)
* adjust attributions in GoogleMapsTilesCredits https://developers.google.com/maps/documentation/tile/create-renderer#display-attributions As it seems it is required to display the attributions sorted by the number of occurences. Additionally multiple attributions should be seperated by semicolon * adjust to correct spacing * adjust spacing * fix code style * remove trailing spaces * add comment where to find the attribution guidelines * move comment to a more prominent place * remove trailing spaces
1 parent 70c3268 commit 07a477c

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/three/renderers/GoogleMapsTilesCredits.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,17 @@ export class GoogleMapsTilesCredits {
4545

4646
toString() {
4747

48-
const tokens = Object.keys( this.creditsCount ).sort();
49-
return tokens.join( ', ' );
48+
// attribution guidelines: https://developers.google.com/maps/documentation/tile/create-renderer#display-attributions
49+
50+
const sortedByCount = Object.entries( this.creditsCount ).sort( ( a, b ) => {
51+
52+
const countA = a[ 1 ];
53+
const countB = b[ 1 ];
54+
return countB - countA; // Descending order
55+
56+
} );
57+
58+
return sortedByCount.map( pair => pair[ 0 ] ).join( '; ' );
5059

5160
}
5261

0 commit comments

Comments
 (0)