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