-
Notifications
You must be signed in to change notification settings - Fork 12
Programming Guide
floledermann edited this page Jul 9, 2015
·
23 revisions
Usually, browser-based applications require an asynchronous programming model using callback functions if external data should be loaded. If multiple data files must be loaded, this can lead to complex code to ensure all resources have been loaded before proceeding with their processing. mapmap.js handles the loading of geometry and data internally and exposes a pseudo-synchronous API that makes sure all resources have been loaded before subsequent operations requiring that data.
// The map will be drawn and the interaction handler installed
// *after* the geometry file has loaded
map.geometry('admin.topojson', 'iso')
.choropleth('population')
.on('click', mapmap.zoom());If you need to execute code after all resources specified so far, you can use the .then() method, providing a callback function.
// The map will be drawn and the interaction handler installed
// *after* the geometry file has loaded
map.geometry('admin.topojson', 'iso')
.choropleth('population')
.then(function(){
console.log("Map loaded!");
});mapmap.js Wiki