MapBuilder
Class for encapsulating a map building operation.
Example:
new MapBuilder()
.specFile('examples/france.yaml')
.onError((err) => {
console.log(err);
})
.onSuccess((data) => {
console.log("Success");
do_something_with_svg_data(data);
})
.build_map();
Method Summary
| Public Methods | ||
| public |
Asynchronously build the map. |
|
| public |
Specify whether to force a rebuild. |
|
| public |
Print information from the shape file specified in the config. |
|
| public |
Specify an error callback for this MapBuilder. |
|
| public |
Specify a success callback for this MapBuilder. |
|
| public |
Specify the configuration to use. |
|
| public |
Specify the configuration to use. |
|
Public Methods
public build_map() source
public force(force: boolean): * source
Specify whether to force a rebuild.
Normally maps are cached based on the specification, but if you update this module you may want to use this option to force the map to be re-created.
Params:
| Name | Type | Attribute | Description |
| force | boolean | whether to force map re-creation. |
Return:
| * |
public get_shape_info() source
Print information from the shape file specified in the config.
Requires onError and onSuccess specified to handle the results.
public onError(err_cb: function(err: string)): * source
Specify an error callback for this MapBuilder.
Return:
| * |
public onSuccess(ok_cb: function(data: string)): * source
Specify a success callback for this MapBuilder.
Return:
| * |
public spec(spec_obj: Object): * source
Specify the configuration to use.
May be used in conjunction with specFile. They will be merged with the spec_obj taking precedence in case of clashes.
Params:
| Name | Type | Attribute | Description |
| spec_obj | Object |
|
object describing the configuration to use. |
Return:
| * |
Example:
var spec_obj = {
"parameters": {
"projection": {
"type": "mercator",
"width": 960,
"height": 1120,
"scale": 1600,
"center": [2, 50]
}
}
}
new MapBuilder()
.spec(spec_obj)
// (Register .onError and .onSuccess callbacks.)
.build_map();