Skip to content

Commit acea997

Browse files
authored
Merge pull request #1407 from MarkTorrey/tiledmaplayer-add-apikey
Add apikey prop to TiledMapLayer
2 parents e827880 + 774a9e9 commit acea997

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

spec/Layers/TiledMapLayerSpec.js

+9
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,15 @@ describe('L.esri.TiledMapLayer', function () {
131131
expect(layer.tileUrl).to.equal('http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer/tile/{z}/{y}/{x}?foo=bar');
132132
});
133133

134+
it('should use an apikey passed in options', function () {
135+
layer = L.esri.tiledMapLayer({
136+
url: url,
137+
apikey: 'abc123'
138+
});
139+
140+
expect(layer.tileUrl).to.equal('http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer/tile/{z}/{y}/{x}?token=abc123');
141+
});
142+
134143
it('should use a token passed with authenticate()', function () {
135144
layer = L.esri.tiledMapLayer({
136145
url: url

src/Layers/TiledMapLayer.js

+5
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ export var TiledMapLayer = TileLayer.extend({
4040
initialize: function (options) {
4141
options = Util.setOptions(this, options);
4242

43+
// support apikey property being passed in
44+
if (options.apikey) {
45+
options.token = options.apikey;
46+
}
47+
4348
// set the urls
4449
options = getUrlParams(options);
4550
this.tileUrl = (options.proxy ? options.proxy + '?' : '') + options.url + 'tile/{z}/{y}/{x}' + (options.requestParams && Object.keys(options.requestParams).length > 0 ? Util.getParamString(options.requestParams) : '');

0 commit comments

Comments
 (0)