Module: slippyMap

Methods

(static) leafletMap(opts) → {module:slippyMap~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 leaflet map.
mapid string The id for the slippy map to be created.
showCountries boolean Indicates whether or not the map will display Country boundaries.
showVcs boolean Indicates whether or not the map will display Vice County boundaries.
showVcsTooltips boolean Indicates whether or not the name and number of the VC should be shown on click. Note that you will need to ensure that the VC has 'fill' style property set to true if you want users to be able to click anywhere within a VC boundary. You can also set the 'fillOpacity' property to 0 if you don't want the fill to be visible. (Note that the default styleVcs properties include these values.)
styleVcs Array.<object> An array of objects defining styles for VCs at different zoom levels. The properties of each can be any that are meaningful to a path object in Leaflet (https://leafletjs.com/reference.html#path-option). Each object also has an property called 'zoom' which can be set to an array of Leaflet zoom levels. The style properties will only be applied if the map zoom level is in the array. A shortcut to indicating all zoom levels not included in other array members is an empty array. If the property includes only one style object, with the zoom property set to an empty array, then the style properties will be applied at all zoom levels.
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.
clusterZoomThreshold number The leaflet zoom level above which clustering will be turned off for point display (except for points in same location) (default 1 - i.e. clustering always one)
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 leaflet map.
width number The desired width of the leaflet map.
basemapConfigs Array.<basemapConfig> An array of map layer configuration objects.
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).
legendOpts legendOpts Sets options for a map legend.
callbacks Array.<function()> An array of callbacks that can be used during data loading/display. Typically these can be used to display/hide busy indicators.
callbacks[0] is fired at the start of data redraw.
callbacks[1] is fired at the end of data redraw.
callbacks[2] is fired at the start of data download.
callbacks[3] is fired at the end of data download.
Source:
Returns:
Returns an API for the map.
Type
module:slippyMap~api

(inner) addBasemapLayer(config)

This function is exposed as a method on the API returned from the leafletMap function. Provides a method to add a basemap layer after the map is created.
Parameters:
Name Type Description
config basemapConfig a configuration object to define the new layer.
Source:

(inner) addGeojsonLayer(config)

This function is exposed as a method on the API returned from the leafletMap function. Provides a method to add a geojson layer after the map is created.
Parameters:
Name Type Description
config geojsonConfig a configuration object to define the new layer.
Source:

(inner) changeClusterThreshold(clusterZoomThreshold)

This function allows you to change the clustering threshold zoom level for point maps.
Parameters:
Name Type Description
clusterZoomThreshold number The leaflet zoom level above which clustering will be turned off.
Source:

(inner) clearMap()

This function is exposed as a method on the API returned from the leafletMap 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 leafletMap function.
Parameters:
Name Type Description
asGeojson boolean a boolean value that indicates whether to generate GeoJson (if false, generates CSV).
Source:

(inner) invalidateSize()

This function is exposed as a method on the API returned from the leafletMap function. Expose the leaflet map invalidate size method.
Source:

(inner) redrawMap()

This function is exposed as a method on the API returned from the leafletMap function. Redraw the map, e.g. after changing map accessor function or map identifier.
Source:

(inner) removeBasemapLayer(mapName)

This function is exposed as a method on the API returned from the leafletMap function. Provides a method to remove a basemap layer after the map is created.
Parameters:
Name Type Description
mapName string the name by which the map layer is identified (appears in layer selection).
Source:

(inner) removeGeojsonLayer(mapName)

This function is exposed as a method on the API returned from the leafletMap function. Provides a method to remove a geojson layer after the map is created.
Parameters:
Name Type Description
mapName string the name by which the map layer is identified.
Source:

(inner) setIdentfier(identifier)

This function is exposed as a method on the API returned from the leafletMap 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 leafletMap 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) setMapType(newMapTypesKey)

This function is exposed as a method on the API returned from the leafletMap 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) setShowCountries(show)

This function allows you to change whether or not Country boundaries are displayed..
Parameters:
Name Type Description
show boolean Indicates whether or not to display Countries.
Source:

(inner) setShowVcs(show)

This function allows you to change whether or not Vice County boundaries are displayed..
Parameters:
Name Type Description
show boolean Indicates whether or not to display VCs.
Source:

(inner) setSize(width, height)

This function is exposed as a method on the API returned from the leafletMap function. Change the size of the leaflet map.
Parameters:
Name Type Description
width number Width of the map.
height number Height of the map.
Source:

(inner) showOverlay(show)

This function allows you to show/hide the leaflet overlay layer (atlas layer). Provides a method to show/hide the leaflet overlay layer used to display atlas data.
Parameters:
Name Type Description
show boolean Set to true to display the layer, or false to hide it.
Source:

Type Definitions

api

Type:
  • Object
Properties:
Name Type Description
setIdentfier module:slippyMap~setIdentfier Identifies data to the data accessor function.
setMapType module:slippyMap~setMapType Set the key of the data accessor function.
setLegendOpts module:slippyMap~setLegendOpts Sets options for the legend.
redrawMap module:slippyMap~redrawMap Redraw the map.
clearMap module:slippyMap~clearMap Clear the map.
setSize module:slippyMap~setSize Reset the size of the leaflet map.
invalidateSize module:slippyMap~invalidateSize Access Leaflet's invalidateSize method.
addBasemapLayer module:slippyMap~addBasemapLayer Add a basemap to the map.
removeBasemapLayer module:slippyMap~removeBasemapLayer Remove a basemap from the map.
addGeojsonLayer module:slippyMap~addGeojsonLayer Add a geojson layer to the map.
removeGeojsonLayer module:slippyMap~removeGeojsonLayer Remove a geojson layer from the map.
showOverlay module:slippyMap~showOverlay Show/hide the overlay layer.
changeClusterThreshold module:slippyMap~changeClusterThreshold Change the zoom cluster threshold for points.
setShowVcs module:slippyMap~setShowVcs Set the boolean flag which indicates whether or not to display VCs.
setShowCountries module:slippyMap~setShowCountries Set the boolean flag which indicates whether or not to display Countries.
downloadData module:slippyMap~downloadData Download a the map data as a CSV or GeoJson file.
lmap module:slippyMap~map Returns a reference to the leaflet map object.
Source:

basemapConfig

Type:
  • Object
Properties:
Name Type Description
name string name of layer to be displayer in layer control.
type string either 'tileLayer' or 'wms'.
selected boolean indicate whether or not this is to be the layer initially selected.
url string the standard leaflet formatted URL for the layer.
opts Object standard leaflet layer options.
Source: