MapService

MapService is an Angular Factory in the SVG module with the name map.js. It provides an API to load geographical maps into SVG layers. To use this API, see the documentation on injecting Angular services.

NameSummary
loadMapRegionIntoSearches for a map in a large datafile and loads a specific map region into to the SVG layer.
loadMapIntoLoad a map region into the SVG layer.

Function Descriptions

loadMapRegionInto

Searches for a map in a large datafile and loads a specific map region into to the SVG layer. This assumes the map file you are providing has multiple maps in it.

Example UsageArgumentsReturn Value

var promise = ms.loadMapRegionInto(mapLayer, filterOpts);

 

Example:

var promise = loadMapRegionInto(svgGroup, {
countryFilter: function (country) {
return country.properties.continent === 'South America';
}
});

mapLayer - d3 selection of an SVG <g> element to load the map into

filterOpts - an object with a member called 'countryFilter'

'countryFilter': function reference that is a filter function to find the country in the file

 a promise to load (asynchronously) the geo-map-data-file

loadMapInto

Load a map region into the SVG layer. This assumes the map file you are providing only has one map in it.

Example UsageArgumentsReturn Value
ms.loadMapInto(mapLayer, id, opts);

mapLayer - d3 selection of an SVG <g> element to load the map into

id - the ID used in fetchTopoData

opts - the opts used in createPathGenerator

a promise to load (asynchronously) the geo-map-data-file