Skip to content

Commit

Permalink
promote glyph source to top level, fixes #513
Browse files Browse the repository at this point in the history
  • Loading branch information
ansis committed Jul 3, 2014
1 parent c72318c commit 209c32e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion debug/style-v3.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"version": 3,
"sprite": "img/sprite",
"glyphs": "http://mapbox.s3.amazonaws.com/gl-glyphs-256/{fontstack}/{range}.pbf",
"constants": {
"@land": "#eee",
"@water": "#999",
Expand All @@ -23,7 +24,6 @@
"mapbox.mapbox-streets-v5": {
"type": "vector",
"url": "mapbox://mapbox.mapbox-streets-v5",
"glyphs": "http://mapbox.s3.amazonaws.com/gl-glyphs-256/{fontstack}/{range}.pbf",
"tileSize": 512
},
"satellite": {
Expand Down
2 changes: 2 additions & 0 deletions js/text/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ function glyphUrl(fontstack, range, url, subdomains) {
}

function loadGlyphRange(tile, fontstack, range, callback) {
if (!tile.glyphs) return callback('no glyph source specified in style');

loading[fontstack] = loading[fontstack] || {};
loading[fontstack][range] = true;

Expand Down
5 changes: 5 additions & 0 deletions js/ui/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ util.extend(Map.prototype, {
this.style.on('change:buckets', this._updateBuckets);

this._updateBuckets();
this._updateGlyphs();
return this.update(true);
},

Expand Down Expand Up @@ -421,6 +422,10 @@ util.extend(Map.prototype, {
this.style.recalculate(this.transform.zoom + this.getZoomAdjustment());
},

_updateGlyphs: function() {
this.dispatcher.broadcast('set glyphs', this.style.stylesheet.glyphs);
},

_updateBuckets: function() {
// Transfer a stripped down version of the style to the workers. They only
// need the bucket information to know what features to extract from the tile.
Expand Down
6 changes: 5 additions & 1 deletion js/worker/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ self['set buckets'] = function(data) {
}
};

self['set glyphs'] = function(data) {
WorkerTile.prototype.glyphs = data;
};

/*
* Load and parse a tile at `url`, and call `callback` with
* (err, response)
Expand All @@ -33,7 +37,7 @@ self['set buckets'] = function(data) {
* @param {function} callback
*/
self['load tile'] = function(params, callback) {
new WorkerTile(params.url, undefined, params.id, params.zoom, params.tileSize, params.glyphs, params.source, callback);
new WorkerTile(params.url, undefined, params.id, params.zoom, params.tileSize, params.source, callback);
};

/*
Expand Down
3 changes: 1 addition & 2 deletions js/worker/workertile.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ var PointVertexBuffer = require('../geometry/pointvertexbuffer.js');
var createBucket = require('../geometry/createbucket.js');

module.exports = WorkerTile;
function WorkerTile(url, data, id, zoom, tileSize, glyphs, source, callback) {
function WorkerTile(url, data, id, zoom, tileSize, source, callback) {
var tile = this;
this.url = url;
this.id = id;
this.zoom = zoom;
this.tileSize = tileSize;
this.glyphs = glyphs;
this.source = source;

this.buffers = {
Expand Down

0 comments on commit 209c32e

Please sign in to comment.