forked from mapbox/mapbox-gl-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Anand Thakker
committed
Aug 12, 2016
1 parent
ad3444b
commit 44d23b5
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'use strict'; | ||
|
||
var Evented = require('../../js/util/evented'); | ||
var util = require('../../js/util/util'); | ||
var formatNumber = require('../lib/format_number'); | ||
|
||
module.exports = function(options) { | ||
var evented = util.extend({}, Evented); | ||
|
||
var mapsOnPage = 6; | ||
|
||
evented.fire('log', { message: 'Creating ' + mapsOnPage + ' maps' }); | ||
|
||
var loaded = 0; | ||
var start = Date.now(); | ||
for (var i = 0; i < mapsOnPage; i++) { | ||
var map = options.createMap({}); | ||
map.on('load', onload.bind(null, map)); | ||
map.on('error', function (err) { | ||
evented.fire('error', err); | ||
}); | ||
} | ||
|
||
function onload () { | ||
if (++loaded >= mapsOnPage) { | ||
var duration = Date.now() - start; | ||
evented.fire('end', { | ||
message: formatNumber(duration) + ' ms, loaded ' + mapsOnPage + ' maps.', | ||
score: duration | ||
}); | ||
done(); | ||
} | ||
} | ||
|
||
function done () { | ||
} | ||
|
||
return evented; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters