Methods
(static) svgMap(opts) → {module:svgMap~api}
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts |
Object | Initialisation options.
Properties
|
- Source:
Returns:
api - Returns an API for the map.
- Type
- module:svgMap~api
(inner) animateTransChange(newTransOptsKey)
This function is exposed as a method on the API returned from the svgMap function.
The method sets a map transformation by selecting the one with the passed in key. It also
redisplays the map but animates the transition between the new transformation object and the
previous.
Parameters:
Name | Type | Description |
---|---|---|
newTransOptsKey |
string | specifies the key of the transformation object in the parent object. |
- Source:
(inner) basemapImage(mapId, show, imageFile, worldFile)
This function is exposed as a method on the API returned from the svgMap function.
The image and world files together make a raster file that can be displayed in GIS. GIS, such as
QGIS can be used to create the image and world file. If you do this, make sure that the image
is created with the same projection as used for the SVG map - i.e. same projection as the vector
data for boundary and/or grid files.
Parameters:
Name | Type | Description |
---|---|---|
mapId |
string | a string which should specify a unique key by which the image can be referenced. |
show |
boolean | a boolean value that indicates whether or not to display this image. |
imageFile |
string | a string identifying an image file. |
worldFile |
string | a string identifying a 'world' file. |
- Source:
(inner) baseMapPriorities(mapIds)
This function is exposed as a method on the API returned from the svgMap function.
The order the keys appear in the array specifies their priority when more than one is displayed
at the same time. Those at the start of the array have higher priority than those and the end.
Parameters:
Name | Type | Description |
---|---|---|
mapIds |
Array.<string> | an array of strings which identify keys of basemap iamges. |
- Source:
(inner) clearMap()
This function is exposed as a method on the API returned from the svgMap function.
Clear the map of dots and legend.
- Source:
(inner) downloadData(asGeojson)
This function is exposed as a method on the API returned from the svgMap function.
Parameters:
Name | Type | Description |
---|---|---|
asGeojson |
boolean | a boolean value that indicates whether to generate GeoJson (if false, generates CSV). |
- Source:
(inner) getMapWidth()
This function is exposed as a method on the API returned from the svgMap function.
Return the width of the map.
- Source:
(inner) redrawMap()
This function is exposed as a method on the API returned from the svgMap function.
Redraw the map, e.g. after changing map accessor function or map identifier.
- Source:
(inner) saveMap(asSvg, svgInfo, filename) → {Promise}
This function is exposed as a method on the API returned from the svgMap function.
Parameters:
Name | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
asSvg |
boolean | a boolean value that indicates whether to generate an SVG (if false, generates PNG image). | ||||||||||||||||||
svgInfo |
Object | Initialisation options. Whole arg can be set to null if no info options.
Properties
|
||||||||||||||||||
filename |
string | Name of the file (without extension) to generate and download. Creates an image from the displayed map and downloads to user's computer. If the filename is falsey (e.g. blank), it will not automatically download the file. (Allows caller to do something else with the data URL which is returned as the promises resolved value.) |
- Source:
Returns:
promise object represents the data URL of the image.
- Type
- Promise
(inner) setBoundary(newGeojson)
This function is exposed as a method on the API returned from the svgMap function.
The method replaces any existing map boundary geojson with the geojson in the file passed. It also
redisplays the map.
Parameters:
Name | Type | Description |
---|---|---|
newGeojson |
string | specifies the path of a geojson object. |
- Source:
(inner) setBoundaryColour(c)
This function is exposed as a method on the API returned from the svgMap function.
Sets the boundary colour to the specified colour.
Parameters:
Name | Type | Description |
---|---|---|
c |
string | a string specifying the colour which can be hex format, e.g. #FFA500, RGB format, e.g. rgb(100, 255, 0) or a named colour, e.g. red. |
- Source:
(inner) setCountryColour(c)
This function is exposed as a method on the API returned from the svgMap function.
Sets the line colour of the countries to the specified colour.
Parameters:
Name | Type | Description |
---|---|---|
c |
string | a string specifying the colour which can be hex format, e.g. #FFA500, RGB format, e.g. rgb(100, 255, 0) or a named colour, e.g. red. |
- Source:
(inner) setCountryLineStyle(c)
This function is exposed as a method on the API returned from the svgMap function.
Sets the line style of the countries to the specified value.
Parameters:
Name | Type | Description |
---|---|---|
c |
string | a string specifying the style which can be set to either none or something else (which will create solid). |
- Source:
(inner) setGrid(newGeojson)
This function is exposed as a method on the API returned from the svgMap function.
The method replaces any existing grid geojson with the geojson in the file passed. It also
redisplays the map.
Parameters:
Name | Type | Description |
---|---|---|
newGeojson |
string | specifies the path of a geojson object. |
- Source:
(inner) setGridColour(c)
This function is exposed as a method on the API returned from the svgMap function.
Sets the grid colour to the specified colour.
Parameters:
Name | Type | Description |
---|---|---|
c |
string | a string specifying the colour which can be hex format, e.g. #FFA500, RGB format, e.g. rgb(100, 255, 0) or a named colour, e.g. red. |
- Source:
(inner) setGridLineStyle(c)
This function is exposed as a method on the API returned from the svgMap function.
Sets the grid style to the specified value.
Parameters:
Name | Type | Description |
---|---|---|
c |
string | a string specifying the style which can be set to either solid, dashed or none. |
- Source:
(inner) setHeight(newHeight)
This function is exposed as a method on the API returned from the svgMap function.
The method resets the height of the main map SVG.
Parameters:
Name | Type | Description |
---|---|---|
newHeight |
string | specifies the height of the SVG object. |
- Source:
(inner) setIdentfier(identifier)
This function is exposed as a method on the API returned from the svgMap function.
The data accessor function, specified elsewhere, will use this identifier to access
the correct data.
Parameters:
Name | Type | Description |
---|---|---|
identifier |
string | a string which identifies some data to a data accessor function. |
- Source:
(inner) setLegendOpts(lo)
This function is exposed as a method on the API returned from the svgMap function.
The legend options object can be used to specify properties of a legend and even the content
of the legend itself.
Parameters:
Name | Type | Description |
---|---|---|
lo |
legendOpts | a legend options object. |
- Source:
(inner) setMapTitle(text, fontSize, x, y)
This function is exposed as a method on the API returned from the svgMap function.
Creates a title which can be positioned independently of the legend. This is useful when the legend needs
to be moved, but the title does not.
Parameters:
Name | Type | Description |
---|---|---|
text |
string | A text value for the map title (can include and tags). |
fontSize |
number | A number indicating font size in pixels. |
x |
number | a number indicating origin x position of text in map svg. |
y |
number | a number indicating origin y position of text in map svg. |
- Source:
(inner) setMapType(newMapTypesKey)
This function is exposed as a method on the API returned from the svgMap function.
The data accessor is stored in the mapTypesSel object and referenced by this key.
Parameters:
Name | Type | Description |
---|---|---|
newMapTypesKey |
string | a string which a key used to identify a data accessor function. |
- Source:
(inner) setProj(newProj)
This function is exposed as a method on the API returned from the svgMap function.
The method replaces any existing map projection so that, for example, a map can be switched between
British and Irish grid projections.
Parameters:
Name | Type | Description |
---|---|---|
newProj |
string | specifies a new projection for the map. |
- Source:
(inner) setTransform(newTransOptsKey)
This function is exposed as a method on the API returned from the svgMap function.
The method sets a map transformation by selecting the one with the passed in key. It also
redisplays the map
Parameters:
Name | Type | Description |
---|---|---|
newTransOptsKey |
string | specifies the key of the transformation object in the parent object. |
- Source:
(inner) setVcColour(c)
This function is exposed as a method on the API returned from the svgMap function.
Sets the colour ov the vice count lines to the specified colour.
Parameters:
Name | Type | Description |
---|---|---|
c |
string | a string specifying the colour which can be hex format, e.g. #FFA500, RGB format, e.g. rgb(100, 255, 0) or a named colour, e.g. red. |
- Source:
(inner) setVcLineStyle(c)
This function is exposed as a method on the API returned from the svgMap function.
Sets the line style of the Vice County lines to the specified value.
Parameters:
Name | Type | Description |
---|---|---|
c |
string | a string specifying the style which can be set to either none or something else (which will create solid). |
- Source:
(inner) showBusy(show)
This function is exposed as a method on the API returned from the svgMap function.
Allows calling application to display/hide an indicator showing the map data is loading.
Parameters:
Name | Type | Description |
---|---|---|
show |
boolean | A boolean value to indicate whether or not to show map data loading. |
- Source:
Type Definitions
api
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
setBoundary |
module:svgMap~setBoundary | Change the map boundary. Pass a single argument which is the path of a geojson file. |
setGrid |
module:svgMap~setGrid | Change the grid lines for the map. Pass a single argument which is the path of a geojson file. |
setBoundaryColour |
module:svgMap~setBoundaryColour | Change the colour of the boundary. Pass a single argument which is a string specifying the colour which can be hex format, e.g. #FFA500, RGB format, e.g. rgb(100, 255, 0) or a named colour, e.g. red. |
setGridColour |
module:svgMap~setGridColour | Change the colour of the grid. Pass a single argument which is a string specifying the colour which can be hex format, e.g. #FFA500, RGB format, e.g. rgb(100, 255, 0) or a named colour, e.g. red. |
setCountryColour |
module:svgMap~setCountryColour | Change the colour of the country boundaries. Pass a single argument which is a string specifying the colour which can be hex format, e.g. #FFA500, RGB format, e.g. rgb(100, 255, 0) or a named colour, e.g. red. |
setVcColour |
module:svgMap~setVcColour | Change the colour of the vice county lines. Pass a single argument which is a string specifying the colour which can be hex format, e.g. #FFA500, RGB format, e.g. rgb(100, 255, 0) or a named colour, e.g. red. |
setGridLineStyle |
module:svgMap~setGridLineStyle | Set the line style of the grid line geoJson. Can be solid, dashed or none. |
setCountryLineStyle |
module:svgMap~setCountryLineStyle | Set the line style of the country boundaries geoJson. Can be none or something else (which will give solid line). |
setVcLineStyle |
module:svgMap~setVcLineStyle | Set the line style of the Vice County line geoJson. Can be none or something else (which will give solid line). |
setTransform |
module:svgMap~setTransform | Set the transformation options object by passing a single argument which is a string indicating the key of the transformation in the parent object. |
getMapWidth |
module:svgMap~getMapWidth | Gets and returns the current width of the SVG map. |
animateTransChange |
module:svgMap~animateTransChange | Set the a new transormation object and animates the transition. |
setIdentfier |
module:svgMap~setIdentfier | Identifies data to the data accessor function. |
setMapType |
module:svgMap~setMapType | Set the key of the data accessor function. |
basemapImage |
module:svgMap~basemapImage | Specifies an image and world file for a basemap. |
baseMapPriorities |
module:svgMap~baseMapPriorities | Identifies the display order of the basemap images. |
setLegendOpts |
module:svgMap~setLegendOpts | Sets options for the legend. |
redrawMap |
module:svgMap~redrawMap | Redraw the map. |
clearMap |
module:svgMap~clearMap | Clear the map. |
saveMap |
module:svgMap~saveMap | Save and download the map as an image. |
downloadData |
module:svgMap~downloadData | Download a the map data as a CSV or GeoJson file. |
setProj |
module:svgMap~setProj | Change the map projection. The argument is a string of the form 'gb', 'ir' or 'ci'. |
setHeight |
module:svgMap~setProj | Reset the height of the main map SVG object. |
showBusy |
module:svgMap~showBusy | Set a boolean value to indicate whether or not to show map data loading. |
- Source: