diff --git a/src/source/load_tilejson.js b/src/source/load_tilejson.js index f3fcfc88582..f26816d1b49 100644 --- a/src/source/load_tilejson.js +++ b/src/source/load_tilejson.js @@ -1,6 +1,6 @@ // @flow -import { pick } from '../util/util'; +import { pick, extend } from '../util/util'; import { getJSON, ResourceType } from '../util/ajax'; import browser from '../util/browser'; @@ -16,8 +16,9 @@ export default function(options: any, requestManager: RequestManager, callback: return callback(err); } else if (tileJSON) { const result: any = pick( - tileJSON, - ['tiles', 'minzoom', 'maxzoom', 'attribution', 'mapbox_logo', 'bounds'] + // explicit source options take precedence over TileJSON + extend(tileJSON, options), + ['tiles', 'minzoom', 'maxzoom', 'attribution', 'mapbox_logo', 'bounds', 'scheme', 'tileSize', 'encoding'] ); if (tileJSON.vector_layers) { diff --git a/src/source/raster_dem_tile_source.js b/src/source/raster_dem_tile_source.js index cf02306b4ef..4407f207ec2 100644 --- a/src/source/raster_dem_tile_source.js +++ b/src/source/raster_dem_tile_source.js @@ -23,7 +23,7 @@ class RasterDEMTileSource extends RasterTileSource implements Source { super(id, options, dispatcher, eventedParent); this.type = 'raster-dem'; this.maxzoom = 22; - this._options = extend({}, options); + this._options = extend({ type: 'raster-dem' }, options); this.encoding = options.encoding || "mapbox"; } diff --git a/src/source/raster_tile_source.js b/src/source/raster_tile_source.js index 5580996c341..ecadfd17241 100644 --- a/src/source/raster_tile_source.js +++ b/src/source/raster_tile_source.js @@ -55,7 +55,7 @@ class RasterTileSource extends Evented implements Source { this.tileSize = 512; this._loaded = false; - this._options = extend({}, options); + this._options = extend({ type: 'raster' }, options); extend(this, pick(options, ['url', 'scheme', 'tileSize'])); } diff --git a/src/style-spec/validate/validate_source.js b/src/style-spec/validate/validate_source.js index 44ec5dceebc..b325eb69508 100644 --- a/src/style-spec/validate/validate_source.js +++ b/src/style-spec/validate/validate_source.js @@ -29,13 +29,6 @@ export default function validateSource(options) { style: options.style, styleSpec }); - if ('url' in value) { - for (const prop in value) { - if (['type', 'url', 'tileSize'].indexOf(prop) < 0) { - errors.push(new ValidationError(`${key}.${prop}`, value[prop], `a source with a "url" property may not include a "${prop}" property`)); - } - } - } return errors; case 'geojson': diff --git a/test/integration/render-tests/tilejson-bounds/overwrite-bounds/expected.png b/test/integration/render-tests/tilejson-bounds/overwrite-bounds/expected.png new file mode 100644 index 00000000000..49bdc006300 Binary files /dev/null and b/test/integration/render-tests/tilejson-bounds/overwrite-bounds/expected.png differ diff --git a/test/integration/render-tests/tilejson-bounds/overwrite-bounds/style.json b/test/integration/render-tests/tilejson-bounds/overwrite-bounds/style.json new file mode 100644 index 00000000000..c19bafe6c9a --- /dev/null +++ b/test/integration/render-tests/tilejson-bounds/overwrite-bounds/style.json @@ -0,0 +1,41 @@ +{ + "version": 8, + "metadata": { + "test": { + "height": 64, + "width":64 + } + }, + "center": [ + 13.425247606101294, 52.5033795378269 + ], + "zoom": 14, + "sources": { + "mapbox": { + "type": "vector", + "maxzoom": 14, + "url": "local://tilesets/vector.json", + "bounds":[13.4043671, 52.4959407, 13.425247606101294, 52.5033795378269] + } + }, + "layers": [ + { + "id": "background", + "type": "background", + "paint": { + "background-color": "white" + } + }, + { + "id": "road", + "type": "line", + "source": "mapbox", + "source-layer": "road", + "paint": { + "line-width": 2, + "line-color": "#000" + } + } + ] + } + \ No newline at end of file diff --git a/test/unit/style-spec/fixture/sources.output.json b/test/unit/style-spec/fixture/sources.output.json index 34674e6aa96..ea691559a05 100644 --- a/test/unit/style-spec/fixture/sources.output.json +++ b/test/unit/style-spec/fixture/sources.output.json @@ -7,14 +7,6 @@ "message": "sources.invalid-type.type: expected one of [vector, raster, raster-dem, geojson, video, image], \"invalid\" found", "line": 7 }, - { - "message": "sources.no-tilejson-properties-with-url.tiles: a source with a \"url\" property may not include a \"tiles\" property", - "line": 12 - }, - { - "message": "sources.no-unknown-properties-with-url.foo: a source with a \"url\" property may not include a \"foo\" property", - "line": 17 - }, { "message": "sources.video-missing-coordinates: missing required property \"coordinates\"", "line": 26