GeoDataService
GeoDataService is an Angular Factory in the SVG module with the name geodata.js
. It provides an API to fetch and cache TopoJSON data from the server, as well as providing a way of creating a path generator for the data to be used to render the map in an SVG layer. To use this API, see the documentation on injecting Angular services.
Name | Summary |
---|---|
clearCache | Clear the cache for TopoJSON data. |
fetchTopoData | Get TopoData via a $http request. |
createPathGenerator | Converts given TopoJSON format data into corresponding GeoJSON data and creates a path generator for it. |
rescaleProjection | Adjust projection scale and translation to fill the view with the map. |
Function Descriptions
clearCache
Clear the cache for TopoJSON data.
Example Usage | Arguments | Return Value |
---|---|---|
gds.clearCache(); | none | none, but clears the cache |
fetchTopoData
Get TopoData via a $http request.
Example Usage | Arguments | Return Value |
---|---|---|
var promise = gds.fetchTopoData(id ); |
| an $http promise object with the following extra members: meta: an object with members id (given), url (used to get the data), and wasCached (boolean) topodata: TopoJSON data upon response from server |
createPathGenerator
Converts given TopoJSON format data into corresponding GeoJSON data and creates a path generator for it.
Example Usage | Arguments | Return Value |
---|---|---|
var pathGen = gds.createPathGnerator(topoData , opts ); |
| an object with the following members: geodata: d3 feature data pathgen: d3 geo path projection settings: the settings object used to create the map |
Default Settings
These can be overwritten in opts
.
var defaultGenSettings = { objectTag: 'states', // the top level member under "objects" tag in TopoJSON projection: d3.geo.mercator(), // type of geo projection, see https://github.com/mbostock/d3/wiki/Geo-Projections logicalSize: 1000, // logical size of the projection mapFillScale: .95 // how large the map fills the area };
rescaleProjection
Adjust projection scale and translation to fill the view with the map.
Example Usage | Arguments | Return Value |
---|---|---|
gds.rescaleProjection(proj , mfs , dim , path , geoData ); | see
| none, but scales and translates the map to fit in the space |