Module: svgMap

Methods

(static) svgMap(opts) → {module:svgMap~api}

Parameters:
Name Type Description
opts Object Initialisation options.
Properties
Name Type Description
selector string The CSS selector of the element which will be the parent of the SVG.
mapid string The id for the static map to be created.
proj string The projection of the map, should be 'gb', 'ir' or 'ci'. It should reflect the projection of boundary and grid data displayed on the map. It is used to generate the 'dots' in the correct location.
captionId string The id of a DOM element into which feature-specific HTML will be displayed as the mouse moves over a dot on the map. The HTML markup must be stored in an attribute called 'caption' in the input data.boundaryFill
onclick function A function that will be called if user clicks on a map element. The function will be passed these attributes, in this order, if they exist on the element: gr, id, caption. (Default - null.)
height number The desired height of the SVG.
expand boolean Indicates whether or not the map will expand to fill parent element.
legendOpts legendOpts Sets options for a map legend.
transOptsSel module:svgCoords~transOptsSel Sets a collection of map transformation options.
transOptsKey string Sets the key of the selected map transformation options. Must be present in as a key in the opts.transOptsSel object.
transOptsControl boolean Indicates whether or not a control should be shown in the bottom-right of the map that can be used display a dialog to change the transformation options.
mapTypesSel Object Sets an object whose properties are data access functions. The property names are the 'keys' which should be human readable descriptiosn of the map types.
mapTypesKey string Sets the key of the selected data accessor function (map type).
mapTypesControl boolean Indicates whether or not a control should be shown in the bottom-right of the map that can be used display a dialog to change the data accessor (map type) options.
boundaryGjson string The URL of a boundary geoJson file to display.
boundaryColour string Specifies the line colour of the boundary geoJson.
boundaryFill string Specifies the fill colour of the boundary geoJson.
boundaryShadowColour string Specifies the colour of a 'glowing' border.
boundaryShadowWidth string Species the width of the glowing border in pixels.
boundaryLineWidth string | number Specifies the width of the line to use for boundary geoJson lines. Can use any valid units for SVG stroke-width. (Default - 1.)
seaFill string Specifies the fill colour of the area outside the boundary geoJson.
insetColour string Specifies the line colour of map inset boxes.
gridGjson string The URL of a grid geoJson file to display.
gridLineColour string Specifies the line colour of grid line geoJson.
gridLineStyle string Specifies the line style of the grid line geoJson. Can be solid, dashed or none. (Default solid.)
gridLineWidth string | number Specifies the width of the line to use for grid lines geoJson. Can use any valid units for SVG stroke-width. (Default - 1.)
vcGjson string The URL of a vice county geoJson file to display.
vcColour string Specifies the line colour of the vice county geoJson.
vcLineStyle string Specifies the line style of the vice county line geoJson. Can none or something else (which gives solid line). (Default none.)
vcLineWidth string | number Specifies the width of the line to use for vice counties geoJson. Can use any valid units for SVG stroke-width. (Default - 1.)
countryGjson string The URL of a country geoJson file to display.
countryColour string Specifies the line colour of the country geoJson.
countryLineStyle string Specifies the line style of the country geoJson. Can none or something else (which gives solid line). (Default none.)
countryLineWidth string | number Specifies the width of the line to use for country lines geoJson. Can use any valid units for SVG stroke-width. (Default - 1.)
legendFont string Specifies the font to use for the legend. (Default - 'sans-serif'.)
legendFontSize string Specifies the font size to use for the legend. (Default - 14px.)
legendInteractivity string Indicates the behaviour of legend interactivity, can be 'mousemove', 'mouseclick' or 'none'. (Default - 'none'.)
highlightClass string For legend interactivity, specify a unique name to use for the highlight class. (Default - ''.)
highlightStyle string For legend interactivity, specify a string of css property and value pairs for highlight style. Separate pairs with semi-colon and property from value with colon. (Default - ''.)
lowlightStyle string For legend interactivity, specify a string of css property and value pairs for lowlight style. Separate pairs with semi-colon and property from value with colon. (Default - ''.)
callbackOptions function Specifies a callback function to be executed if user options dialog used.
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
Name Type Description
text string A text string to be displayed at the foot of the map. This will be word-wrapped to the width of the image. Some HTML tags, e.g. are recognised, but in order to facilitate word wrapping, each word must be marked up separately - there should be no white space within the tag.
textFormatted Array.<string> An array of strings to be concatenated anddisplayed at the foot of the map. Each element in the array is preceded by one of the of the following tokens which indicates how it is to be formatted: n# indicates no formatting; i# indicates italics and b# indicates emboldening. This resultig string will be word-wrapped to the width of the image.
img string The path of an image to be displayed at the foot of the map. If the image is wider than the SVG, it is rescaled to the size of the SVG.
fontSize number The size of the font to be used for the text string (defaults to 12)
margin number The size of a margin, in pixels, to be placed around the text and/or image.
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: