X-Git-Url: http://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=tim%2Fprune%2Fgui%2Fmap%2FOsmMapSource.java;fp=tim%2Fprune%2Fgui%2Fmap%2FOsmMapSource.java;h=925fcf623ea456154c512c5e5e89454eb5b46bf8;hp=070bb258510c578cd7e102863017408b2727093c;hb=92dad5df664287acb51728e9ea599f150765d34a;hpb=81843c3d8d0771bf00d0f26034a13aa515465c78 diff --git a/tim/prune/gui/map/OsmMapSource.java b/tim/prune/gui/map/OsmMapSource.java index 070bb25..925fcf6 100644 --- a/tim/prune/gui/map/OsmMapSource.java +++ b/tim/prune/gui/map/OsmMapSource.java @@ -19,6 +19,9 @@ public class OsmMapSource extends MapSource private String[] _siteNames = null; /** Maximum zoom level */ private int _maxZoom = 0; + /** API key, usually remains empty */ + private String _apiKey = null; + /** * Constructor giving single name and url @@ -93,6 +96,12 @@ public class OsmMapSource extends MapSource _maxZoom = inMaxZoom; } + /** Set the API key (if required) */ + public void setApiKey(String inKey) + { + _apiKey = inKey; + } + /** * Construct a new map source from its config string * @param inConfigString string from Config, separated by semicolons @@ -147,8 +156,15 @@ public class OsmMapSource extends MapSource public String makeURL(int inLayerNum, int inZoom, int inX, int inY) { // Check if the base url has a [1234], if so replace at random - return pickServerUrl(_baseUrls[inLayerNum]) - + inZoom + "/" + inX + "/" + inY + "." + getFileExtension(inLayerNum); + StringBuffer url = new StringBuffer(); + url.append(pickServerUrl(_baseUrls[inLayerNum])); + url.append(inZoom).append('/').append(inX).append('/').append(inY); + url.append('.').append(getFileExtension(inLayerNum)); + if (_apiKey != null) + { + url.append("?apikey=").append(_apiKey); + } + return url.toString(); } /**