-
Notifications
You must be signed in to change notification settings - Fork 9
Base Configuration
If multiple people in your organization may want to use Mapboard to make mapping apps, they will probably want to use many of the same aspects of a map, or same datasets. Creating a base configuration file which multiple apps can link to removes the need to define basemaps, data sources, and other frequently-used options in every application.
There is one in the City of Philadelphia's Github account that anyone can use: mapboard-default-base-config
You access it using jsDelivr and a Github commit:
var BASE_CONFIG_URL = 'https://cdn.jsdelivr.net/gh/cityofphiladelphia/mapboard-default-base-config@d3ad38f050cf55b4ab0dc2ff68e6f18025690246/config.js';
Instead of containing a simple js object, a base configuration must contain an immediately-invoked function expression (IIFE) which contains a js object. This allows us to pass values from the config to the baseconfig, as "opts."
The top of your base configuration may start:
(function () {
return function (opts) {
return {
geocoder: {
url: function (input) {
var inputEncoded = encodeURIComponent(input);
return '//api.phila.gov/ais/v1/search/' + inputEncoded;
},
params: {
gatekeeperKey: opts.gatekeeperKey,
include_units: true,
},
},
map: {
center: [-75.163471, 39.953338]...
and the bottom may look like this:
...carto: {
baseUrl: '//phl.carto.com/api/v2/sql',
},
};
}
})();
Right now the only "opt" that that is passed to the baseconfig is the gatekeeperKey, but others could be added.
A base configuration file should include the following objects: