Skip to main content

Class: MapSVGMap

MapSVGMap class. Creates a new map inside of the given HTML container, which is typically a DIV element.

The class constructor is available in the global varialbe, as mapsvg.map.

Example usage:

const map = new mapsvg.map("my-container-id", {
id: "my-map",
options: {
source: "/path/to/map.svg",
zoom: {on: true},
scroll: {on: true}
}
});

// Get map instance by container ID
const map = mapsvg.getById("my-map");

// Get map instance by index (in the order of creation)
const map_1 = mapsvg.get(0) // first map
const map_2 = mapsvg.get(1) // second map

Accessors

_scale

Get Signature

get _scale(): number;

Get relative map scale from initial zoom level

Returns

number


zoomLevel

Get Signature

get zoomLevel(): number;

Current map zoom level

Returns

number

Constructors

Constructor

new MapSVGMap(
containerId,
mapParams,
params): MapSVGMap;

Initializes a new instance of the Map class.

Parameters

ParameterTypeDescription
containerIdstringThe ID of the HTML element that will contain the map.
mapParams{ id?: number; options?: MapOptions; svgFileLastChanged?: string | number; version?: string; }An object containing map parameters such as ID, options, SVG file last changed timestamp, and version.
mapParams.id?number-
mapParams.options?MapOptions-
mapParams.svgFileLastChanged?string | number-
mapParams.version?string-
params{ [key: string]: any; inBackend?: boolean; prefetch?: boolean; }Additional parameters for the map, including options for prefetching and backend mode.
params.inBackend?boolean-
params.prefetch?boolean-

Returns

MapSVGMap

Methods

_new_setChoropleth()

_new_setChoropleth(options?): void;

Sets choropleth map options

Parameters

ParameterTypeDescription
options?any

Returns

void

Example

mapsvg.setChoropleth({
on: true,
colors: {
high: "#FF0000",
low: "#00FF00"
}
labels: {
high: "high",
low: "low"
}
});

addObject()

addObject(object): void;

Parameters

ParameterType
objectModel

Returns

void


attachDataToRegions()

attachDataToRegions(object?): void;

Attaches DB Objects to Regions

Parameters

ParameterTypeDescription
object?Model

Returns

void


bubblesRegionsMoveScreenPositionBy()

bubblesRegionsMoveScreenPositionBy(deltaX, deltaY): void;

Move position of Regions bubbles by given numbers

Parameters

ParameterTypeDescription
deltaXnumber
deltaYnumber

Returns

void


centerOn()

centerOn(centerOnObject?, yShift?): ViewBox;

Centers map on Region or Marker.

Parameters

ParameterTypeDescription
centerOnObject?| GeoPoint | Marker | Region | SVGPoint | SVGPointLiteral | GeoPointLiteralRegion or Marker
yShift?numberVertical shift from center. Used by showPopover method to fit popover in the map container

Returns

ViewBox


checkIfZoomIsNeeded()

checkIfZoomIsNeeded(viewBox): boolean;

Parameters

ParameterType
viewBoxViewBox

Returns

boolean


clearDirtyFields()

clearDirtyFields(): void;

Returns

void


convertMouseToSVG()

convertMouseToSVG(e): SVGPoint;

Converts mouse pointer coordinates to SVG coordinates

Parameters

ParameterTypeDescription
eTriggeredEventEvent object

Returns

SVGPoint

  • [x,y] SVG coordinates

createContainers()

createContainers(): void;

Returns

void


createGoogleMapOverlay()

createGoogleMapOverlay(bounds, map): GoogleMapsOverlay;

Parameters

ParameterType
boundsany
mapany

Returns

GoogleMapsOverlay


createToolbar()

createToolbar(): void;

Returns

void


deleteClusters()

deleteClusters(): void;

Delete all clusters from the map

Returns

void


deleteMarkers()

deleteMarkers(): void;

Delete all markers

Returns

void


deselectAllMarkers()

deselectAllMarkers(): void;

Deselects all Markers

Returns

void


deselectAllRegions()

deselectAllRegions(): void;

Deselects all Regions

Returns

void


deselectMarker()

deselectMarker(marker): void;

Deselects one Marker

Parameters

ParameterTypeDescription
markerMarker

Returns

void


deselectRegion()

deselectRegion(region): void;

Deselects one Region

Parameters

ParameterTypeDescription
regionRegion

Returns

void


destroy()

destroy(): void;

Destroys the map and all related containers.

Returns

void


directoryFilterOut()

directoryFilterOut(items): any;

Filter out directory items

Parameters

ParameterType
itemsany

Returns

any


extractField()

extractField(
region,
object,
path,
callback): void;

Parameters

ParameterType
regionRegion
object| Model | Region
pathstring
callback(value) => void

Returns

void


fitMarkers()

fitMarkers(): void;

Changes maps viewBox to fit loaded markers.

Returns

void


fitViewBox()

fitViewBox(viewBox, forceZoomLevel?): boolean;

Parameters

ParameterType
viewBoxViewBox
forceZoomLevel?number

Returns

boolean


getAdjustedSvgDefaultViewBox()

getAdjustedSvgDefaultViewBox(): ViewBox;

Returns

ViewBox


getBubbleSize()

getBubbleSize(region): any;

Returns size of the choropleth bubble

Parameters

ParameterType
regionRegion

Returns

any


getCenterGeoPoint()

getCenterGeoPoint(fromZeroLevel, viewBox?): GeoPoint;

Returns lat,lng coordinates of center of the current view

Parameters

ParameterTypeDefault value
fromZeroLevelbooleanfalse
viewBox?ViewBoxundefined

Returns

GeoPoint


getCenterSvgPoint()

getCenterSvgPoint(fromZeroLevel, viewBox?): SVGPoint;

Returns SVG coordinates of the center of current map position

Parameters

ParameterTypeDefault value
fromZeroLevelbooleanfalse
viewBox?ViewBoxundefined

Returns

SVGPoint


getChoroplethColor()

getChoroplethColor(region): string;

Returns color of the Region for choropleth map

Parameters

ParameterType
regionRegion

Returns

string

color


getContainer()

getContainer(name): HTMLElement;

Parameters

ParameterType
namestring

Returns

HTMLElement


getConverter()

getConverter(): Converter;

Returns

Converter


getData()

getData(): object;

Returns

object

id
id: number;
options
options: MapOptions;
svgFileLastChanged
svgFileLastChanged: number;
title
title: string;
version
version: string;

getDb()

getDb(): Repository;

Returns Database

Returns

Repository

Example

var objects = mapsvg.getDb().getLoaded();
var object = mapsvg.getDb().getLoadedObject(12);

// Filter DB by region "US-TX". This automatically triggers markers and directory reloading
mapsvg.getDatabase().getAll({filters: {regions: "US-TX"}});

getDbRegions()

getDbRegions(): Repository;

Returns Regions database

Returns

Repository


getDirtyFields()

getDirtyFields(): object;

Returns

object


getEditingMarker()

getEditingMarker(): Marker;

Returns marker that is currently in the "edit mode" Used in Map Editor.

Returns

Marker


getGeoBounds()

getGeoBounds(viewBox?): object;

Retrieves the geographical boundaries of the map.

Parameters

ParameterType
viewBox?ViewBox

Returns

object

  • Returns an object with south-west and north-east geographical points.
ne
ne: GeoPoint;
sw
sw: GeoPoint;

getGeoViewBox()

getGeoViewBox(): number[];

Returns geo-bounds of the map.

Returns

number[]

  • [leftLon, topLat, rightLon, bottomLat]

getGroupBBox()

getGroupBBox(mapObjects): ViewBox;

Parameters

ParameterType
mapObjects( | Marker | Region | MarkerCluster)[]

Returns

ViewBox


getGroupBounds()

getGroupBounds(objects): object;

Parameters

ParameterType
objects( | Marker | Region | MarkerCluster)[]

Returns

object

ne
ne: GeoPoint;
sw
sw: GeoPoint;

getGroupSelectOptions()

getGroupSelectOptions(): any[];

Returns the list of options for visibility settings in admin.js

Returns

any[]


getLayer()

getLayer(name): HTMLElement;

Returns layer by provided name

Parameters

ParameterTypeDescription
namestring

Returns

HTMLElement


getMarker()

getMarker(id): Marker;

Finds a Marker by ID

Parameters

ParameterTypeDescription
idstringMarker ID

Returns

Marker

Example

var marker = mapsvg.getMarker("marker_12");

getOptions()

getOptions(forTemplate, forWeb): MapOptions;

Returns map options.

Parameters

ParameterTypeDescription
forTemplatebooleanIf options should be formatted for use in a template
forWebbooleanIf options should be formatted for use in the web

Returns

MapOptions


getPagination()

getPagination(callback?): HTMLElement;

Generates HTML with pagination buttons and attaches callback event on button click

Parameters

ParameterTypeDescription
callback?() => voidCallback function that should be called on click on a next/prev page button

Returns

HTMLElement


getRegion()

getRegion(id): Region;

Finds a Region by ID

Parameters

ParameterTypeDescription
idstringRegion ID

Returns

Region

Example

var region = mapsvg.getRegion("US-TX");

getRegions()

getRegions(): ArrayIndexed<Region>;

Returns all Regions

Returns

ArrayIndexed<Region>


getRegionStylesByState()

getRegionStylesByState(region): RegionStylesByStatus;

Parameters

ParameterType
regionRegion

Returns

RegionStylesByStatus


getRelativeScale()

getRelativeScale(): number;

Calculates the relative scale of the map. The relative scale is the ratio of the width of the adjusted SVG default viewBox to the width of the current viewBox.

Returns

number

The relative scale of the map.


getScale()

getScale(): number;

Returns current SVG scale related to screen - map screen pixels to SVG points ratio. Example: if SVG current viewBox width is 600 and the map is shown in a 300px container, the map scale is 0.5 (300/600 = 0.5)

Returns

number

Map scale related to screen


getSelected()

getSelected(): string[];

Returns array of IDs of selected Regions

Returns

string[]


getUserLocation()

getUserLocation(callback): boolean;

Gets user's current location by using browser's HTML5 geolocation feature. Works only under HTTPS connection!

Parameters

ParameterTypeDescription
callback(coordinates) => voidCallback to be called when user location is received

Returns

boolean

  • false if geolocation is unavailable, or true if it's available

getViewBox()

getViewBox(): ViewBox;

Returns current viewBox

Returns

ViewBox

ViewBox


getViewBoxByState()

getViewBoxByState(type): ViewBox;

Parameters

ParameterType
type"custom" | "initial" | "svg"

Returns

ViewBox


getZoomLevelByViewBox()

getZoomLevelByViewBox(viewBox, forceZoomLevel?): ViewBox;

Parameters

ParameterType
viewBoxViewBox
forceZoomLevel?number

Returns

ViewBox


getZoomLevelViewBox()

getZoomLevelViewBox(level): ViewBox;

Calculates ViewBox for a specific zoom level on demand

Parameters

ParameterTypeDescription
levelnumberTarget zoom level

Returns

ViewBox

ViewBox for the specified zoom level


getZoomRange()

getZoomRange(): object;

Returns

object

max
max: number;
min
min: number;

googleFitCurrentGeoBounds()

googleFitCurrentGeoBounds(): void;

Returns

void


handleLinkClick()

handleLinkClick(e): void;

Parameters

ParameterType
eTriggeredEvent

Returns

void


hidePopover()

hidePopover(): void;

Hides the popover

Returns

void


highlightMarker()

highlightMarker(marker): void;

Highlight marker

Parameters

ParameterTypeDescription
markerMarker

Returns

void


highlightRegions()

highlightRegions(regions): void;

Highlights an array of Regions (used on mouseover)

Parameters

ParameterTypeDescription
regionsRegion[]

Returns

void


initMap()

initMap(_options, data?): Promise<void>;

Parameters

ParameterType
_optionsMapOptions
data?any

Returns

Promise<void>


isGeo()

isGeo(): boolean;

Checks if the map is geo-calibrated

Returns

boolean


isLinkClicked()

isLinkClicked(e): boolean;

Parameters

ParameterType
eany

Returns

boolean


isRegionDisabled()

isRegionDisabled(id, svgfill): boolean;

Checks if Region should be disabled

Parameters

ParameterTypeDescription
idstringRegion ID
svgfillstringRegion color ("fill" attribute)

Returns

boolean

  • "true" if Region should be disabled.

labelsRegionsMoveScreenPositionBy()

labelsRegionsMoveScreenPositionBy(deltaX, deltaY): void;

Move position of Region Labels by given numbers

Parameters

ParameterTypeDescription
deltaXnumber
deltaYnumber

Returns

void


linkObjectToRegions()

linkObjectToRegions(object): void;

Connect object to regions

Parameters

ParameterTypeDescription
objectModelObject to connect

Returns

void


loadDataObjects()

loadDataObjects(params?): JQueryDeferred<any>;

Parameters

ParameterType
params?any

Returns

JQueryDeferred<any>


loadDirectory()

loadDirectory(): void;

Returns

void


loadFiltersController()

loadFiltersController(container, modal): void;

Loads filters controller into a provided container

Parameters

ParameterTypeDefault valueDescription
containerHTMLElementundefinedContainer, jQuery object
modalbooleanfalseIf filter should be in a modal window

Returns

void


loadItemsToDirectory()

loadItemsToDirectory(): boolean;

Loads items from a source defined in settings to the directory. The source can be "Regions" or "Database".

Returns

boolean


loadMap()

loadMap(id, container): void;

Gets map settings from the server

Parameters

ParameterType
idstring | number
containerHTMLElement

Returns

void


loadMockRegions()

loadMockRegions(): void;

Returns

void


loadPreviousMap()

loadPreviousMap(): void;

Load previous map from the history (MapSVGMap.options.previousMapsIds)

Returns

void


loadSvgFile()

loadSvgFile(svgFileUrl, svgFileLastChanged): Promise<void | Response>;

Parameters

ParameterTypeDefault value
svgFileUrlanyundefined
svgFileLastChangednumber1

Returns

Promise<void | Response>


markerAdd()

markerAdd(marker): void;

Adds a marker to the map.

Parameters

ParameterTypeDescription
markerany

Returns

void

Example

let location = new mapsvg.location({
geoPoint: new mapsvg.geoPoint({lat: 55.12, lng: 46.19}),
img: "/path/to/image.png"
});

let marker = new mapsvg.marker({
location: location,
mapsvg: mapInstance
});

// The marker is created but still not added to the map. Let's add it:
mapInstance.markerAdd(marker);

markerAddClickHandler()

markerAddClickHandler(e): void;

Event handler that creates marker on click on the map. Used in the Map Editor.

Parameters

ParameterTypeDescription
eTriggeredEventEvent object

Returns

void


markerClickHandler()

markerClickHandler(e, marker): void;

Parameters

ParameterType
eTriggeredEvent
markerMarker

Returns

void


markerClusterClickHandler()

markerClusterClickHandler(e, markerCluster): void;

Parameters

ParameterType
eTriggeredEvent
markerClusterMarkerCluster

Returns

void


markerDelete()

markerDelete(marker): void;

Deletes a marker

Parameters

ParameterTypeDescription
markerMarker

Returns

void


markerRemove()

markerRemove(marker): void;

Removes marker from the map

Parameters

ParameterTypeDescription
markerMarker

Returns

void


markersAdjustScreenPosition()

markersAdjustScreenPosition(): void;

Adjusts position of Markers and MarkerClusters. This method is called on zoom or when map container is resized.

Returns

void


markersClusterAdd()

markersClusterAdd(markersCluster): void;

Adds a marker cluster

Parameters

ParameterTypeDescription
markersClusterMarkerCluster

Returns

void


markersMoveScreenPositionBy()

markersMoveScreenPositionBy(deltaX, deltaY): void;

Move Markers and clusters by given numbers.

Parameters

ParameterTypeDescription
deltaXnumber
deltaYnumber

Returns

void


mouseWheelZoom()

mouseWheelZoom(event): void;

Parameters

ParameterType
eventMouseEventBase<any, any, any, any>

Returns

void


objectsLoadedToMapHandler()

objectsLoadedToMapHandler(): void;

Returns

void


panBy()

panBy(x, y): object;

Shift the map by x,y pixels

Parameters

ParameterTypeDescription
xnumber
ynumber

Returns

object

x
x: boolean;
y
y: boolean;

pickChoroplethColor()

pickChoroplethColor(choroplethValue): object;

For choropleth map: returns color for given number value

Parameters

ParameterTypeDescription
choroplethValuenumberNumber value

Returns

object

  • Color values, 0-255.
a
a: number;
b
b: number;
g
g: number;
r
r: number;

popoverAdjustScreenPosition()

popoverAdjustScreenPosition(): void;

Adjusts popover position. User on zoom and when map container is resized.

Returns

void


popoverMoveScreenPositionBy()

popoverMoveScreenPositionBy(deltaX, deltaY): void;

Moves popover position. User on zoom and when map container is resized.

Parameters

ParameterTypeDescription
deltaXnumber
deltaYnumber

Returns

void


popoverOffHandler()

popoverOffHandler(e): void;

Event handler that catches clicks outside of the popover and closes the popover.

Parameters

ParameterTypeDescription
eTriggeredEventEvent object

Returns

void


redraw()

redraw(): void;

Redraws the map. Must be called when the map is shown after being hidden.

Returns

void


redrawBubbles()

redrawBubbles(): void;

Redraws choropleth bubbles.

Returns

void


regionClickHandler()

regionClickHandler(e, region): void;

Parameters

ParameterType
eTriggeredEvent
regionRegion

Returns

void


reloadAllRegionStyles()

reloadAllRegionStyles(): void;

Redraws colors of regions. Used when Region statuses are loaded from the database or when choropleth map is enabled.

Returns

void


reloadRegions()

reloadRegions(): void;

Reloads Regions from SVG file

Returns

void


reloadRegionsFull()

reloadRegionsFull(): void;

Reloads Regions data

Returns

void


reloadRegionStyles()

reloadRegionStyles(region): void;

Parameters

ParameterType
regionRegion

Returns

void


requestZoom()

requestZoom(): boolean;

Returns

boolean


scrollStart()

scrollStart(e, mapsvg): void;

Event handler - called when map scroll starts

Parameters

ParameterTypeDescription
eTouchEventBase
mapsvgMapSVGMap

Returns

void


seFilterTags()

seFilterTags(): void;

Returns

void


selectMarker()

selectMarker(marker): void;

Selects a Marker

Parameters

ParameterTypeDescription
markerMarker

Returns

void


selectRegion()

selectRegion(id, skipDirectorySelection?): void;

Selects a Region

Parameters

ParameterTypeDescription
idstring | RegionRegion or ID
skipDirectorySelection?boolean

Returns

void


setActions()

setActions(options): void;

Sets map actions that should be performed on Region click. Marker click, etc.

Parameters

ParameterTypeDescription
optionsany

Returns

void

Example

mapsvg.setActions({
"click.region": {
showPopover: true,
showDetails: false
}
})

setCenter()

Call Signature

setCenter(point): SVGPoint;
Parameters
ParameterType
pointSVGPoint
Returns

SVGPoint

Call Signature

setCenter(point): GeoPoint;
Parameters
ParameterType
pointGeoPoint
Returns

GeoPoint


setChoropleth()

setChoropleth(options?): void;

Sets choropleth map options

Parameters

ParameterTypeDescription
options?any

Returns

void

Example

mapsvg.setGauge({
on: true,
colors: {
high: "#FF0000",
low: "#00FF00"
}
labels: {
high: "high",
low: "low"
}
});

setChoroplethSourceField()

setChoroplethSourceField(field): void;

Sets the field that is used for choropleth map

Parameters

ParameterTypeDescription
fieldanyfield name

Returns

void


setColors()

setColors(colors?): void;

Sets color settings (background, regions, containers, etc.)

Parameters

ParameterTypeDescription
colors?{ [key: string]: string | number | Record<string, unknown>; }

Returns

void

Example

mapsvg.setColors({
background: "#EEEEEE",
hover: "10",
selected: "20",
leftSidebar: "#FF2233",
detailsView: "#FFFFFF"
});

setContainers()

setContainers(options): void;

Sets container options: leftSidebar, rightSidebar, header, footer.

Parameters

ParameterTypeDescription
optionsany

Returns

void

Example

mapsvg.setContainers({
leftSidebar: {
on: true,
width: "300px"
}
});

setControls()

setControls(options): void;

Sets map control buttons.

Parameters

ParameterTypeDescription
optionsanycontrol button options

Returns

void

Example

mapsvg.setControls({
location: 'right',
zoom: true,
zoomReset: true,
userLocation: true,
previousMap: true
});

setCursor()

setCursor(type): void;

Sets mouse pointer cursor style on hover on regions / markers.

Parameters

ParameterTypeDescription
typeany"pointer" or "default"

Returns

void


setDatabase()

setDatabase(options?): void;

Sets database options.

Parameters

ParameterTypeDescription
options?any

Returns

void

Example

mapsvg.setDatabase({
pagination: {on: true, perpage: 30}
});

setDetailsView()

setDetailsView(options?): void;

Sets Details View options

Parameters

ParameterTypeDescription
options?{ [key: string]: any; }Options

Returns

void


setDirectory()

setDirectory(options): void;

Sets directory options.

Parameters

ParameterTypeDescription
optionsany

Returns

void

Alias

setMenu

Example

mapsvg.setDirectory({
on: true,
container: "leftSidebar"
});

setDisableAll()

setDisableAll(on): void;

Disables all Regions if "true" is passed.

Parameters

ParameterTypeDescription
onboolean

Returns

void


setDisableLinks(on): void;

Disables/enables redirection by link on click on a region or marker when "Go to link..." feature is enabled Used to prevent redirection in the map editor.

Parameters

ParameterTypeDescription
onbooleantrue (enable redirection) of false (disable)

Returns

void


setEditingMarker()

setEditingMarker(marker): void;

Sets marker into "edit mode". Used in Map Editor.

Parameters

ParameterTypeDescription
markerMarker

Returns

void


setEvents()

setEvents(functions, unique?): void;

Sets event handlers

Parameters

ParameterTypeDescription
functions{ [key: string]: string; }Object containing the event handlers: {eventName: callback, eventName2: callback}
unique?boolean-

Returns

void


setFilters()

setFilters(options?): void;

Sets filter options

Parameters

ParameterTypeDescription
options?{ [key: string]: any; }

Returns

void

Example

mapsvg.setFilters{{
on: true,
location: "leftSidebar"
}};

setFiltersSchema()

setFiltersSchema(filtersSchema?): void;

Sets the filters schema for the map. The filters schema defines the available filters for the map.

Parameters

ParameterTypeDescription
filtersSchema?any[]An array of filter fields. Each field is an object with the following properties: - id (string): The unique identifier of the filter field. - title (string): The title of the filter field. - type (string): The type of the filter field. Supported types are: "text", "select", "checkbox", "radio", "range". - options (object): Additional options for the filter field. The options depend on the filter type.

Returns

void


setFitSingleMarkerZoom()

setFitSingleMarkerZoom(zoom): void;

Parameters

ParameterType
zoomany

Returns

void


setGoogleMaps()

setGoogleMaps(options?): void;

Sets Google Map options.

Parameters

ParameterTypeDescription
options?any

Returns

void

Example

mapsvg.setGoogleMaps({
on: true,
type: "terrain"
});

// Get Google Maps instance:
var gm = mapsvg.googleMaps.map;

setLabelsMarkers()

setLabelsMarkers(options?): void;

Sets Marker labels

Parameters

ParameterTypeDescription
options?any

Returns

void


setLabelsRegions()

setLabelsRegions(options?): void;

Parameters

ParameterType
options?any

Returns

void


setLoadingText()

setLoadingText(message): void;

Updates the loading text message displayed on the map

Parameters

ParameterTypeDescription
messagestringThe text to display while the map is loading

Returns

void


setMiddleware()

setMiddleware<T>(
name,
handler,
unique): void;

Type Parameters

Type Parameter
T extends MiddlewareType

Parameters

ParameterTypeDefault value
nameTundefined
handlerMiddlewareHandlers[T]undefined
uniquebooleanfalse

Returns

void


setMiddlewares()

setMiddlewares(functions, unique): void;

Parameters

ParameterTypeDefault value
functions{ mapLoad: | string | MapLoadMiddleware; render: | string | RenderMiddleware; request: | string | RequestMiddleware; response: | string | ResponseMiddleware; }undefined
functions.mapLoad| string | MapLoadMiddlewareundefined
functions.render| string | RenderMiddlewareundefined
functions.request| string | RequestMiddlewareundefined
functions.response| string | ResponseMiddlewareundefined
uniquebooleanfalse

Returns

void


setMobileView()

setMobileView(options): void;

Sets mobile view options

Parameters

ParameterTypeDescription
optionsany

Returns

void


setMultiSelect()

setMultiSelect(on, deselect?): void;

Enables/disables "multiselect" option that allows to select multiple regions.

Parameters

ParameterTypeDescription
onboolean
deselect?booleanIf true, deselects currently selected Regions

Returns

void


setObjectClickedBeforeScroll()

setObjectClickedBeforeScroll(object): void;

Save the Region ID that was clicked before starting map scroll. It is used to trigger .regionClickHandler() later if scroll was less than 5px

Parameters

ParameterType
object| Marker | Region | MarkerCluster

Returns

void


setPagination()

setPagination(): void;

Adds pagination controls to the map and/or directory

Returns

void


setPopovers()

setPopovers(options): void;

Sets popover options.

Parameters

ParameterTypeDescription
optionsany

Returns

void

Example

mapsvg.setPopovers({
on: true,
width: 300, // pixels
maxWidth: 70, // percents of map container
maxHeight: 70, // percents of map container
mobileFullscreen: true
});

setRatio()

setRatio(ratio): void;

Parameters

ParameterType
rationumber

Returns

void


setRegionEditHandler()

setRegionEditHandler(handler): void;

Sets callback function that is called on click on a Region. Used in the Map Editor on click on a Region in the "Edit regions" map mode.

Parameters

ParameterTypeDescription
handler() => void

Returns

void


setRegions()

setRegions(options): void;

Parameters

ParameterType
optionsRegionOptionsCollection

Returns

void


setRepositoryEvents()

setRepositoryEvents(): void;

Returns

void


setResponsive()

setResponsive(on): void;

Sets map responsiveness on/off. When map is responsive, it takes the full width of the parent container.

Parameters

ParameterTypeDescription
onboolean

Returns

void


setScroll()

setScroll(options, skipEvents): void;

Sets map scroll options.

Parameters

ParameterTypeDescription
optionsanyscroll options
skipEventsanyused by Map Editor to prevent re-setting event handlers.

Returns

void

Example

mapsvg.setScroll({
on: true,
limit: false // limit scroll to map bounds
});

setSize()

setSize(
width,
height,
responsive?): void;

Sets map container size. Can accept both or just 1 parameter - width or height. The missing parameter will be calcualted.

Parameters

ParameterTypeDescription
widthnumber
heightnumber
responsive?boolean

Returns

void

  • [width, height]

setSvgFileLastChanged()

setSvgFileLastChanged(val): void;

Parameters

ParameterType
valnumber

Returns

void


setTemplates()

setTemplates(templates): void;

Sets templates body

Parameters

ParameterTypeDescription
templatesanyKey:value pairs of template names and HTML content

Returns

void


setTooltips()

setTooltips(options): void;

Sets tooltips options.

Parameters

ParameterTypeDescription
options{ on: boolean; }
options.onboolean-

Returns

void

Example

mapsvg.setTooltips({
on: true,
position: "bottom-left",
maxWidth: "300"
})

setViewBox()

setViewBox(viewBox?, adjustGoogleMap?): boolean;

Sets map viewbox

Parameters

ParameterTypeDefault valueDescription
viewBox?ViewBoxundefined
adjustGoogleMap?booleantrue

Returns

boolean


setViewBoxByGoogleMapBounds()

setViewBoxByGoogleMapBounds(): void;

Sets SVG viewBox by Google Maps bounds. Used to overlay SVG map on Google Map.

Returns

void


setViewBoxByGoogleMapsOverlay()

setViewBoxByGoogleMapsOverlay(): void;

Returns

void


setWhRatio()

setWhRatio(ratio): void;

Parameters

ParameterType
rationumber

Returns

void


setZoom()

setZoom(options): void;

Sets map zoom options.

Parameters

ParameterTypeDescription
optionsanyzoom options

Returns

void

Example

mapsvg.setZoom({
on: true,
mousewheel: true,
limit: [-5,10], // allow -5 zoom steps back and +20 zoom steps up from initial position.
});

setZoomLevel()

setZoomLevel(zoomLevel): void;

Parameters

ParameterType
zoomLevelnumber

Returns

void


showDetails()

showDetails(obj, templateName?): void;

Loads Details View for an object (Region or DB Object)

Parameters

ParameterTypeDescription
obj| Model | Region
templateName?string

Returns

void

Example

var region = mapsvg.getRegion("US-TX");
mapsvg.loadDetailsView(region);

var object = mapsvg.database.getLoadedObject(12);
mapsvg.loadDetailsView(object);

showPopover()

showPopover(object, templateName?): void;

Shows a popover for provided Region or DB Object.

Parameters

ParameterTypeDescription
object| Model | RegionRegion or DB Object
templateName?string-

Returns

void

Example

var region = mapsvg.getRegion("US-TX");
mapsvg.showPopover(region);

showTooltip()

showTooltip(object, templateName?): void;

Parameters

ParameterType
object| Marker | Region | MarkerCluster
templateName?string

Returns

void


showUserLocation()

showUserLocation(callback): void;

Shows user current location Works only under HTTPS connection

Parameters

ParameterTypeDescription
callback(location) => voidCallback to be called when user location is received

Returns

void


unhighlightMarker()

unhighlightMarker(): void;

Unhighlights all Regions (used on mouseout)

Returns

void


unhighlightRegions()

unhighlightRegions(): void;

Unhighlights all Regions (used on mouseout)

Returns

void


update()

update(options): void;

Updates map settings.

Parameters

ParameterTypeDescription
optionsOmit<MapOptions, "id">Map options

Returns

void

Example

mapsvg.update({
popovers: {on: true},
colors: {
background: "red"
}
});

updateGoogleMapsMaxZoom()

updateGoogleMapsMaxZoom(geoPoint): void;

Parameters

ParameterType
geoPointGeoPoint

Returns

void


viewBoxReset()

viewBoxReset(type): ViewBox;

Resets the map zoom and scroll to the initial position.

Parameters

ParameterTypeDefault value
type"custom" | "initial" | "svg""custom"

Returns

ViewBox

The new ViewBox after the reset.


viewBoxSetBySize()

viewBoxSetBySize(width, height): ViewBox;

Adjusts the size of the map container and viewBox simultaneously. This method is ideal for scenarios where both the map container and viewBox sizes need to be modified.

Parameters

ParameterTypeDescription
widthnumberThe desired width for the map container
heightnumberThe desired height for the map container

Returns

ViewBox

The updated viewBox object


zoom()

zoom(zoomLevel, center?): void;

Adjusts the map's zoom level

Parameters

ParameterTypeDescription
zoomLevelnumberThe target zoom level
center?SVGPointOptional: The center point for zooming

Returns

void


zoomIn()

zoomIn(center?): void;

Zooms-in the map

Parameters

ParameterTypeDescription
center?SVGPointif provided, zoom will shift the center point

Returns

void


zoomOut()

zoomOut(center?): void;

Zooms-out the map

Parameters

ParameterTypeDescription
center?SVGPointCenter point (optional)

Returns

void


zoomTo()

zoomTo(mapObjects, zoomToLevel?): boolean;

Zooms to Region, Marker or array of Markers.

Parameters

ParameterTypeDescription
mapObjects| Marker | Region | Region[] | MarkerCluster | Marker[] | MarkerCluster[]Region ID, Region, Marker, array of Markers, array of MarkerClusters
zoomToLevel?numberZoom level

Returns

boolean

Example

var region = mapsvg.getRegion("US-TX");
mapsvg.zoomTo(region);

Properties

_viewBox

_viewBox: ViewBox;

Initial viewBox


$gauge

$gauge: any;

afterLoadBlockers

afterLoadBlockers: number;

AfterLoad event can be blocked by:

  1. Loading Google API JS files
  2. Loading filters controller When a blocker is introduced, it increases the number of afterLoadBlockers when mapsvg.finalizeMapLoading is called, it checks if afterLoadBlockers = 0

canZoom

canZoom: boolean;

changedFields

changedFields: any;

changedSearch

changedSearch: any;

clickAddsMarker

clickAddsMarker: boolean;

clusterizerWorker

clusterizerWorker: Worker;

Clusterizer worker


clustersFromWorker

clustersFromWorker: MarkerCluster[];

Sets of pre-calculated clusters for every zoom level


containerId

containerId: string;

containers

containers: object = {};

Map containers

choroplethSourceSelect?

optional choroplethSourceSelect: object;
choroplethSourceSelect.container
container: HTMLElement;
choroplethSourceSelect.options
options: HTMLElement[];
choroplethSourceSelect.select
select: HTMLElement;

clustersCss?

optional clustersCss: HTMLStyleElement;

clustersHoverCss?

optional clustersHoverCss: HTMLStyleElement;

controls?

optional controls: HTMLElement;

detailsView?

optional detailsView: HTMLElement;

Details view container

directory?

optional directory: HTMLElement;

Directory container

filters?

optional filters: HTMLElement;

Filters container

filtersModal?

optional filtersModal: HTMLElement;

filterTags?

optional filterTags: HTMLElement;
optional footer: HTMLElement;

googleMaps?

optional googleMaps: HTMLElement;

Google Maps container

optional header: HTMLElement;

layers?

optional layers: HTMLElement;

Layers container

layersControl?

optional layersControl: HTMLElement;

Layers controls container

layersControlLabel?

optional layersControlLabel: HTMLElement;

layersControlList?

optional layersControlList: HTMLElement;

layersControlListNano?

optional layersControlListNano: HTMLElement;
optional leftSidebar: HTMLElement;

legend?

optional legend: object;
legend.coloring
coloring: HTMLElement;
legend.container
container: HTMLElement;
legend.description
description: HTMLElement;
legend.text
text: HTMLElement;
legend.title
title: HTMLElement;

loading?

optional loading: HTMLElement;

Container for "Loading map..." message

map?

optional map: HTMLElement;

Map container

mapContainer?

optional mapContainer: HTMLElement;

Parent map container

markersCss?

optional markersCss: HTMLStyleElement;

pagerDir?

optional pagerDir: HTMLElement;

pagerMap?

optional pagerMap: HTMLElement;

popover?

optional popover: HTMLElement;

Popover container

optional rightSidebar: HTMLElement;

scrollpane?

optional scrollpane: HTMLElement;

Scrolling container

scrollpaneWrap?

optional scrollpaneWrap: HTMLElement;

Wrapper of scrolling container

svg?

optional svg: SVGSVGElement;

SVG image container

toolbar?

optional toolbar: HTMLElement;

tooltipCluster?

optional tooltipCluster: HTMLElement;

Tooltip container

tooltipMarker?

optional tooltipMarker: HTMLElement;

Tooltip container

tooltipRegion?

optional tooltipRegion: HTMLElement;

Tooltip container

wrap?

optional wrap: HTMLElement;

Wrapper of map container

wrapAll?

optional wrapAll: HTMLElement;

Main wrapper for all containers

zoomButtons?

optional zoomButtons: HTMLElement;

containersCreated

containersCreated: boolean = false;

controllerMiddleWare

controllerMiddleWare: MiddlewareHandler;

controllers

controllers: object = {};

Map controllers

Example:

const { popover } = map.controllers
popover.show()

detailsView?

optional detailsView: DetailsController;

directory?

optional directory: DirectoryController;

filters?

optional filters: FiltersController;

popover?

optional popover: PopoverController;

toolbar?

optional toolbar: ToolbarController;

tooltips?

optional tooltips: object;
tooltips.cluster?
optional cluster: Tooltip;
tooltips.marker?
optional marker: Tooltip;
tooltips.region?
optional region: Tooltip;

controls

controls: object;

previousMap

previousMap: HTMLElement;

userLocation

userLocation: HTMLElement;

zoom

zoom: HTMLElement;

zoomReset

zoomReset: HTMLElement;

converter

converter: Converter;

defaults

defaults: MapOptions;

dirtyFields

dirtyFields: string[] = [];

disableLinks: boolean;

editData

editData: object;

on

on: boolean;

editingMarker

editingMarker: Marker;

Reference to a Marker currently edited (dragged)


editMarkers

editMarkers: object;

on

on: boolean;

editRegions

editRegions: object;

on

on: boolean;

events

events: Events;

eventsBaseInitialized

eventsBaseInitialized: boolean = false;

eventsPreventList

eventsPreventList: object = {};

Index Signature

[key: string]: boolean

extras

extras: object;

Index Signature

[key: string]: any

prefetch?

optional prefetch: boolean;

filtersRepository

filtersRepository: Repository;

filtersSchema

filtersSchema: Schema;

Schema for the map filters (set of fields and their parameters)


firefoxScroll

firefoxScroll: object;

insideIframe

insideIframe: boolean;

scrollX

scrollX: number;

scrollY

scrollY: number;

firstDataLoad

firstDataLoad: boolean;

Flag indicating first data load


fitDelta

fitDelta: number;

fitOnDataLoadDone

fitOnDataLoadDone: boolean;

formBuilder

formBuilder: any;

galleries

galleries: ArrayIndexed<GalleryOptionsInterface>;

geoCoordinates

geoCoordinates: boolean = false;

geoViewBox

geoViewBox: GeoViewBox;

Geo ViewBiox, containing to geo-points: SW(lat,lng) and NE(lat,lng)


googleMaps?

optional googleMaps: object;

currentMaxZoom?

optional currentMaxZoom: number;

initialized

initialized: boolean;

loaded

loaded: boolean;

map

map: Map;

maxZoomService?

optional maxZoomService: MaxZoomService;

overlay?

optional overlay: any;

zoomLimit?

optional zoomLimit: boolean;

googleMapsScript

googleMapsScript: HTMLScriptElement;

groups

groups: ArrayIndexed<GroupOptionsInterface>;

highlighted_marker

highlighted_marker: Marker;

highlightedRegions

highlightedRegions: Region[] = [];

id

id: number;

inBackend

inBackend: boolean;

initialZoomLevel

initialZoomLevel: number;

Initial zoom level


iosDownscaleFactor

iosDownscaleFactor: number;

Flag defining whether map needs to be downscaled or upscaled to prevent blurring on iOS devices


isScrolling

isScrolling: boolean = false;

isZooming

isZooming: boolean;

Flag defining whether the map is zooming at the moment


lastTimeFitWas

lastTimeFitWas: number;

layers

layers: object = {};

Index Signature

[key: string]: HTMLElement

liveCss

liveCss: HTMLStyleElement;

loaded

loaded: boolean;

locationField

locationField: SchemaField;

mapDataLoaded

mapDataLoaded: boolean = false;

mapDataPromise

mapDataPromise: Promise<void | Response>;

mapIsGeo

mapIsGeo: boolean;

mapLatBottomDegree

mapLatBottomDegree: number;

mapLonDelta

mapLonDelta: number;

markerEditHandler()

markerEditHandler: (location) => void;

Parameters

ParameterType
locationLocation

Returns

void


markerOptions

markerOptions: Record<string, unknown>;

markers

markers: ArrayIndexed<Marker>;

Array of Markers

Example:

map.markers.forEach(marker => marker.hide())

markersClusters

markersClusters: ArrayIndexed<MarkerCluster>;

Array of Marker clusters


middlewares

middlewares: MiddlewareList;

objectClickedBeforeScroll

objectClickedBeforeScroll: 
| Marker
| Region
| MarkerCluster;

objects

objects: ArrayIndexed<Model>;

objectsRepository

objectsRepository: Repository;

options

options: MapOptions;

optionsDelta

optionsDelta: object;

Index Signature

[key: string]: any

popoverShowingFor

popoverShowingFor: MapObject;

regionEditHandler()

regionEditHandler: () => void;

Returns

void


regions

regions: ArrayIndexed<Region>;

regionsRepository

regionsRepository: Repository;

resizeSensor

resizeSensor: ResizeSensor;

scale

scale: number = 1;

Current map scale relative to original size


scaleDistStart

scaleDistStart: number;

schemaRepository

schemaRepository: SchemaRepository;

scroll

scroll: object;

Scroll coordinates

dx?

optional dx: number;

dy?

optional dy: number;

gx?

optional gx: number;

gy?

optional gy: number;

touchScrollStart

touchScrollStart: number;

tx?

optional tx: number;

ty?

optional ty: number;

vx?

optional vx: number;

vxi?

optional vxi: number;

vy?

optional vy: number;

vyi?

optional vyi: number;

x?

optional x: number;

y?

optional y: number;

scrollStarted

scrollStarted: boolean;

selected_id

selected_id: string[] = [];

An array of selected reion IDs


selected_marker

selected_marker: Marker;

A reference ot currently selected marker


setMarkersByField

setMarkersByField: boolean;

superScale

superScale: number;

svgDefault

svgDefault: object = {};

geoViewBox?

optional geoViewBox: GeoViewBox;

height?

optional height: number;

viewBox?

optional viewBox: ViewBox;

width?

optional width: number;

svgFileLastChanged

svgFileLastChanged: number;

svgFileLoaded

svgFileLoaded: boolean = false;

svgFileLoadedPromise

svgFileLoadedPromise: Promise<boolean>;

svgFileLoadedResolve()

svgFileLoadedResolve: (value) => void;

Parameters

ParameterType
valueboolean | PromiseLike<boolean>

Returns

void


svgFilePromise

svgFilePromise: Promise<void | Response>;

templates

templates: object;

Handlebars templates (for Details View, Popover, etc.)

Index Signature

[key: string]: any

tooltip

tooltip: object;

mirror

mirror: object;
Index Signature
[key: string]: number

posOriginal

posOriginal: object;
Index Signature
[key: string]: string

posShifted

posShifted: object;
Index Signature
[key: string]: string

posShiftedPrev

posShiftedPrev: object;
Index Signature
[key: string]: string

touchZoomStart

touchZoomStart: boolean;

userLocation

userLocation: Location;

userLocationMarker

userLocationMarker: Marker;

vbStart

vbStart: boolean;

version

version: string;

viewBox

viewBox: ViewBox;

Current viewBox


whRatio

whRatio: object;

Width/height ratio

current

current: number;

original

original: number;

zoomDelta

zoomDelta: number = 0;

zoomLevels

zoomLevels: ArrayIndexed<ZoomLevel>;

The list of all zoom levels, with viewBoxes