Ignore:
Timestamp:
2017-05-16T19:00:23+02:00 (7 years ago)
Author:
bastik
Message:

see #josm14796 - various improvements for JMapViewer (patch by Chris Tipper)

File:
1 edited

Legend:

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

    r31790 r33313  
    11// License: GPL. For details, see Readme.txt file.
    22package org.openstreetmap.gui.jmapviewer.tilesources;
     3
     4import java.io.IOException;
     5
     6import org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate;
    37
    48/**
     
    6367        }
    6468    }
     69
     70    /**
     71     * The "Transport Map" OSM tile source.
     72     *
     73     * Template for thunderforest.com
     74     */
     75    public static class TransportMap extends AbstractOsmTileSource {
     76
     77        private static final String API_KEY = "API_KEY_HERE";
     78
     79        private static final String PATTERN = "https://%s.tile.thunderforest.com/transport";
     80
     81        private static final String[] SERVER = { "a", "b", "c" };
     82
     83        private int serverNum;
     84
     85        /**
     86         * Constructs a new {@code TransportMap} tile source.
     87         */
     88        public TransportMap() {
     89            super("OSM Transport Map", PATTERN, "osmtransportmap");
     90        }
     91
     92        @Override
     93        public String getBaseUrl() {
     94            String url = String.format(this.baseUrl, new Object[] {SERVER[serverNum]});
     95            serverNum = (serverNum + 1) % SERVER.length;
     96            return url;
     97        }
     98
     99        @Override
     100        public int getMaxZoom() {
     101            return 18;
     102        }
     103
     104        @Override
     105        public String getTileUrl(int zoom, int tilex, int tiley) throws IOException {
     106            return this.getBaseUrl() + getTilePath(zoom, tilex, tiley); // + "?apikey=" + API_KEY;
     107        }
     108
     109        @Override
     110        public String getAttributionText(int zoom, ICoordinate topLeft, ICoordinate botRight) {
     111            return "Maps © Thunderforest, Data © OpenStreetMap contributors";
     112        }
     113
     114        @Override
     115        public String getAttributionLinkURL() {
     116            return "http://www.thunderforest.com/";
     117        }
     118    }
     119
    65120}
Note: See TracChangeset for help on using the changeset viewer.