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
public OsmMapSource(String inName, String inStr1, String inStr2, int inMaxZoom)
{
if (inStr2 != null && inStr2.length() == 3)
- init(inName, inStr1, inStr2, null, null, 18);
+ init(inName, inStr1, inStr2, null, null, inMaxZoom);
else
- init(inName, inStr1, "png", inStr2, "png", 18);
+ init(inName, inStr1, "png", inStr2, "png", inMaxZoom);
}
/**
_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
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();
}
/**