MapsvgClient
Class: MapsvgClient
Section titled “Class: MapsvgClient”Client class, globally available as mapsvg or window.mapsvg.
It contains all of the classes and utilities.
Example usage:
// Init objectsconst map = new mapsvg.map(...)const location = new mapsvg.location(...)
// Get mapconst map = mapsvg.getById(12)
// Use utilitiesif(mapsvg.utils.env.isPhone()) { // do something for mobile devices}
const capitalizedString = map.utils.strings.ucfirst("orange") // > OrangeExtends
Section titled “Extends”Accessors
Section titled “Accessors”googleMapsApiKey
Section titled “googleMapsApiKey”Get Signature
Section titled “Get Signature”get googleMapsApiKey(): string;Returns
Section titled “Returns”string
Inherited from
Section titled “Inherited from”Get Signature
Section titled “Get Signature”get nonce(): string;Returns
Section titled “Returns”string
Set Signature
Section titled “Set Signature”set nonce(_nonce): void;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
_nonce | string |
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new MapsvgClient(): MapsvgClient;Returns
Section titled “Returns”MapsvgClient
Overrides
Section titled “Overrides”Methods
Section titled “Methods”addInstance()
Section titled “addInstance()”addInstance(mapsvg): void;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
mapsvg | any |
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”extend()
Section titled “extend()”extend(sub, base): void;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
sub | any |
base | any |
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”extendBuiltins()
Section titled “extendBuiltins()”extendBuiltins(): void;Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”get(index): MapSVGMap;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
index | any |
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”getByContainerId()
Section titled “getByContainerId()”getByContainerId(id): MapSVGMap;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id | any |
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”getById()
Section titled “getById()”getById(id): MapSVGMap;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id | any |
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”init()
Section titled “init()”init(options): Promise<void>;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options | MapsvgFrontendParams |
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”lazyLoadMap()
Section titled “lazyLoadMap()”lazyLoadMap(container): void;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
container | HTMLElement |
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”loadMap()
Section titled “loadMap()”loadMap(container): void;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
container | HTMLElement |
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”loadMaps()
Section titled “loadMaps()”loadMaps(): void;Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”receiveMessageFromIframe()
Section titled “receiveMessageFromIframe()”receiveMessageFromIframe(event): void;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
event | any |
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”Mapsvg.receiveMessageFromIframe
setEventHandlers()
Section titled “setEventHandlers()”setEventHandlers(): void;Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”unloadMaps()
Section titled “unloadMaps()”unloadMaps(): void;Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”createClient()
Section titled “createClient()”static createClient(frontEndOptions?): Mapsvg;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
frontEndOptions? | MapsvgFrontendParams |
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”Properties
Section titled “Properties”_nonce
Section titled “_nonce”_nonce: string;Inherited from
Section titled “Inherited from”arrayIndexed
Section titled “arrayIndexed”arrayIndexed: typeof ArrayIndexed = ArrayIndexed;customObject
Section titled “customObject”customObject: typeof Model = Model;defaultMarkerImage
Section titled “defaultMarkerImage”defaultMarkerImage: string;Inherited from
Section titled “Inherited from”distanceSearch
Section titled “distanceSearch”distanceSearch: any;Inherited from
Section titled “Inherited from”formBuilder
Section titled “formBuilder”formBuilder: typeof FormBuilder = FormBuilder;geoPoint
Section titled “geoPoint”geoPoint: typeof GeoPoint = GeoPoint;google_maps_api_key
Section titled “google_maps_api_key”google_maps_api_key: string;Inherited from
Section titled “Inherited from”googleMaps
Section titled “googleMaps”googleMaps: object;apiIsLoading
Section titled “apiIsLoading”apiIsLoading: boolean;apiKey
Section titled “apiKey”apiKey: string;loaded
Section titled “loaded”loaded: boolean;onLoadCallbacks
Section titled “onLoadCallbacks”onLoadCallbacks: () => void[];Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”googleMapsApiLoaded
Section titled “googleMapsApiLoaded”googleMapsApiLoaded: boolean = false;Inherited from
Section titled “Inherited from”initialized
Section titled “initialized”initialized: boolean;Overrides
Section titled “Overrides”instances
Section titled “instances”instances: MapSVGMap[];Inherited from
Section titled “Inherited from”loaded
Section titled “loaded”loaded: boolean = false;Inherited from
Section titled “Inherited from”location
Section titled “location”location: typeof Location = Location;map: typeof MapSVGMap = MapSVGMap;mapsRepository
Section titled “mapsRepository”mapsRepository: typeof MapsRepository = MapsRepository;mapsV2Repository
Section titled “mapsV2Repository”mapsV2Repository: typeof MapsV2Repository = MapsV2Repository;marker
Section titled “marker”marker: typeof Marker = Marker;markerImages
Section titled “markerImages”markerImages: object[];file: string;folder
Section titled “folder”folder: string;relativeUrl?
Section titled “relativeUrl?”optional relativeUrl: string;url: string;Inherited from
Section titled “Inherited from”mediaUploader
Section titled “mediaUploader”mediaUploader: any;Inherited from
Section titled “Inherited from”meta: Record<string, any> = {};Inherited from
Section titled “Inherited from”mouse: object;x: number;y: number;Inherited from
Section titled “Inherited from”query: typeof Query = Query;region
Section titled “region”region: typeof Region = Region;repository
Section titled “repository”repository: typeof Repository = Repository;ResizeSensor
Section titled “ResizeSensor”ResizeSensor: typeof ResizeSensor;Inherited from
Section titled “Inherited from”routes
Section titled “routes”routes: MapsvgRoutes;Inherited from
Section titled “Inherited from”schema
Section titled “schema”schema: typeof Schema = Schema;schemaRepository
Section titled “schemaRepository”schemaRepository: typeof SchemaRepository = SchemaRepository;screenPoint
Section titled “screenPoint”screenPoint: typeof ScreenPoint = ScreenPoint;server
Section titled “server”server: typeof Server = Server;svgPoint
Section titled “svgPoint”svgPoint: {(x?, y?, z?, w?): DOMPoint; prototype: DOMPoint; fromPoint: DOMPoint;} = SVGPoint;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
x? | number |
y? | number |
z? | number |
w? | number |
Returns
Section titled “Returns”DOMPoint
prototype
Section titled “prototype”prototype: DOMPoint;fromPoint()
Section titled “fromPoint()”fromPoint(other?): DOMPoint;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
other? | DOMPointInit |
Returns
Section titled “Returns”DOMPoint
templatesLoaded
Section titled “templatesLoaded”templatesLoaded: Record<string, boolean> = {};Inherited from
Section titled “Inherited from”useRepository()
Section titled “useRepository()”useRepository: { (name, map): Repository; (name, map): Repository; (name, map): SchemaRepository; (name, map): MapsRepository; (name, map): PostTypesRepository;};Call Signature
Section titled “Call Signature”(name, map): Repository;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
name | | "regions" | ["regions", string] | SchemaOptions |
map | MapSVGMap |
Returns
Section titled “Returns”Call Signature
Section titled “Call Signature”(name, map): Repository;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
name | | SchemaOptions | "objects" | ["objects", string] |
map | MapSVGMap |
Returns
Section titled “Returns”Call Signature
Section titled “Call Signature”(name, map): SchemaRepository;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
name | | SchemaOptions | "schemas" |
map | MapSVGMap |
Returns
Section titled “Returns”Call Signature
Section titled “Call Signature”(name, map): MapsRepository;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
name | | SchemaOptions | "maps" |
map | MapSVGMap |
Returns
Section titled “Returns”Call Signature
Section titled “Call Signature”(name, map): PostTypesRepository;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
name | | SchemaOptions | ["postTypes", string] |
map | MapSVGMap |
Returns
Section titled “Returns”utils: object;env: object;env.getBrowser()
Section titled “env.getBrowser()”getBrowser: () => object;Gets browser info (IE, Firefox, Safari).
Returns
Section titled “Returns”object
firefox
Section titled “firefox”firefox: boolean;ie: boolean;safari
Section titled “safari”safari: boolean;env.getDevice()
Section titled “env.getDevice()”getDevice: () => object;Detects if the device is iOS or Android.
Returns
Section titled “Returns”object
android
Section titled “android”android: boolean;ios: boolean;env.getMouseCoords()
Section titled “env.getMouseCoords()”getMouseCoords: (e) => object;Gets mouse or touch coordinates from an event.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
e | MouseEvent | TouchEvent | TriggeredEvent<any, any, any, any> |
Returns
Section titled “Returns”object
x: number;y: number;env.getUserAgent()
Section titled “env.getUserAgent()”getUserAgent: () => string;Gets the user agent string in lowercase.
Returns
Section titled “Returns”string
env.isMac()
Section titled “env.isMac()”isMac: () => boolean;Checks if the current OS is Mac.
Returns
Section titled “Returns”boolean
env.isPhone()
Section titled “env.isPhone()”isPhone: () => boolean;Checks if the device is a phone (max-width: 767px).
Returns
Section titled “Returns”boolean
files: object;files.getFileType()
Section titled “files.getFileType()”getFileType: (url) => "JS" | "CSS" | "Unknown";Gets the file type from a URL.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
url | any |
Returns
Section titled “Returns”"JS" | "CSS" | "Unknown"
“JS”, “CSS”, or “Unknown”
files.loadFile()
Section titled “files.loadFile()”loadFile: (file) => Promise<unknown>;Loads a single JS or CSS file.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
file | any |
Returns
Section titled “Returns”Promise<unknown>
files.loadFiles()
Section titled “files.loadFiles()”loadFiles: (files) => Promise<any[]>;Loads multiple files (JS or CSS).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
files | any |
Returns
Section titled “Returns”Promise<any[]>
funcs: object;funcs.deepMerge()
Section titled “funcs.deepMerge()”deepMerge: {<T, U> (target, source): T & U;<T, U, V> (target, middle, source): T & U & V;};Call Signature
Section titled “Call Signature”<T, U>(target, source): T & U;Deep merges two or three objects.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T |
U |
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
target | T | |
source | U |
Returns
Section titled “Returns”T & U
Call Signature
Section titled “Call Signature”<T, U, V>( target, middle, source): T & U & V;Deep merges two or three objects.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T |
U |
V |
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
target | T | |
middle | U | |
source | V |
Returns
Section titled “Returns”T & U & V
funcs.geocode()
Section titled “funcs.geocode()”geocode: (query, callback) => boolean;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
query | any |
callback | any |
Returns
Section titled “Returns”boolean
funcs.getNestedValue()
Section titled “funcs.getNestedValue()”getNestedValue: (obj, path) => any;Gets a nested value from an object using dot or PHP-style bracket notation.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
obj | any | The object to traverse. |
path | string | The path string (e.g. ‘a.b.c’ or ‘a[b][c]’). |
Returns
Section titled “Returns”any
The value at the nested path, or undefined if not found.
Example
Section titled “Example”getNestedValue(obj, 'a.b.c')getNestedValue(obj, 'a[b][c]')funcs.splitObjectAndField()
Section titled “funcs.splitObjectAndField()”splitObjectAndField: (fields) => object;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
fields | string |
Returns
Section titled “Returns”object
field: string;object
Section titled “object”object: string;funcs.throttle()
Section titled “funcs.throttle()”throttle: (method, delay, scope, params) => void;Throttles a function call by a delay.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
method | any | |
delay | any | |
scope | any | |
params | any |
Returns
Section titled “Returns”void
http: object;http.handleFailedRequest()
Section titled “http.handleFailedRequest()”handleFailedRequest: (response) => void;Handles a failed AJAX request and shows a growl error.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
response | any |
Returns
Section titled “Returns”void
numbers
Section titled “numbers”numbers: object;numbers.compareVersions()
Section titled “numbers.compareVersions()”compareVersions: (v1, v2) => -1 | 0 | 1;Compares two version strings (e.g. “1.2.3”).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
v1 | any | |
v2 | any |
Returns
Section titled “Returns”-1 | 0 | 1
1 if v1 > v2, -1 if v1 < v2, 0 if equal
numbers.isNumber()
Section titled “numbers.isNumber()”isNumber: (n) => boolean;Checks if a value is a number.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
n | any |
Returns
Section titled “Returns”boolean
numbers.parseBoolean()
Section titled “numbers.parseBoolean()”parseBoolean: (string) => boolean;Parses a string to boolean.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
string | any |
Returns
Section titled “Returns”boolean
strings
Section titled “strings”strings: object;strings.convertToText()
Section titled “strings.convertToText()”convertToText: (obj) => any;Converts an object to a string representation.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
obj | any |
Returns
Section titled “Returns”any
strings.fixColorHash()
Section titled “strings.fixColorHash()”fixColorHash: (color) => string;Adds a hash to a color string if missing.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
color | string |
Returns
Section titled “Returns”string
strings.functionFromString()
Section titled “strings.functionFromString()”functionFromString: (string) => SyntaxError | TypeError;Converts a string to a function.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
string | string |
Returns
Section titled “Returns”SyntaxError | TypeError
Function or object {error: "error text"}
strings.removeLeadingSlash()
Section titled “strings.removeLeadingSlash()”removeLeadingSlash: (str) => any;Removes a leading slash from a string.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
str | any |
Returns
Section titled “Returns”any
strings.safeURL()
Section titled “strings.safeURL()”safeURL: (url) => any;Normalizes a URL by removing the protocol and domain.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
url | any |
Returns
Section titled “Returns”any
strings.toSnakeCase()
Section titled “strings.toSnakeCase()”toSnakeCase: (str) => string;Converts a string to snake_case.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
str | string |
Returns
Section titled “Returns”string
strings.ucfirst()
Section titled “strings.ucfirst()”ucfirst: (string) => any;Uppercases the first character of a string.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
string | any |
Returns
Section titled “Returns”any
version
Section titled “version”version: string = "process.env.VERSION";Inherited from
Section titled “Inherited from”initialized
Section titled “initialized”static initialized: boolean = false;