Skip to content

Commit

Permalink
adjust attributions in GoogleMapsTilesCredits (#497)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
tobias74 authored Mar 5, 2024
1 parent 70c3268 commit 07a477c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/three/renderers/GoogleMapsTilesCredits.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,17 @@ export class GoogleMapsTilesCredits {

toString() {

const tokens = Object.keys( this.creditsCount ).sort();
return tokens.join( ', ' );
// attribution guidelines: https://developers.google.com/maps/documentation/tile/create-renderer#display-attributions

const sortedByCount = Object.entries( this.creditsCount ).sort( ( a, b ) => {

const countA = a[ 1 ];
const countB = b[ 1 ];
return countB - countA; // Descending order

} );

return sortedByCount.map( pair => pair[ 0 ] ).join( '; ' );

}

Expand Down

0 comments on commit 07a477c

Please sign in to comment.