Ignore:
Timestamp:
2019-05-30T15:32:13+02:00 (6 years ago)
Author:
donvip
Message:

see #17744 - allow to configure Bing API key

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java

    r34766 r35017  
    4343public class BingAerialTileSource extends TMSTileSource {
    4444
     45    /** Setting key for Bing metadata API URL. Must contain {@link #API_KEY_PLACEHOLDER} */
     46    public static final String METADATA_API_SETTING = "jmapviewer.bing.metadata-api-url";
     47    /** Setting key for Bing API key */
     48    public static final String API_KEY_SETTING = "jmapviewer.bing.api-key";
     49    /** Placeholder to specify Bing API key in metadata API URL*/
     50    public static final String API_KEY_PLACEHOLDER = "{apiKey}";
     51
     52    /** Bing Metadata API URL */
     53    private static final String METADATA_API_URL =
     54            "https://dev.virtualearth.net/REST/v1/Imagery/Metadata/Aerial?include=ImageryProviders&output=xml&key=" + API_KEY_PLACEHOLDER;
     55    /** Original Bing API key created by Potlatch2 developers in 2010 */
    4556    private static final String API_KEY = "Arzdiw4nlOJzRwOz__qailc8NiR31Tt51dN2D7cm57NrnceZnCpgOkmJhNpGoppU";
    4657    private static volatile Future<List<Attribution>> attributions; // volatile is required for getAttribution(), see below.
     
    95106
    96107    protected URL getAttributionUrl() throws MalformedURLException {
    97         return new URL("https://dev.virtualearth.net/REST/v1/Imagery/Metadata/Aerial?include=ImageryProviders&output=xml&key="
    98                 + API_KEY);
     108        return new URL(FeatureAdapter.getSetting(METADATA_API_SETTING, METADATA_API_URL)
     109                .replace(API_KEY_PLACEHOLDER, FeatureAdapter.getSetting(API_KEY_SETTING, API_KEY)));
    99110    }
    100111
Note: See TracChangeset for help on using the changeset viewer.