jsbeans

jsbeans  1.0.0

jsbeans > jsbeans > jsbeans.GMaps
Search:
 
Filters

Class jsbeans.GMaps

Utility Object to check availability of Google Maps™ API during loading cycle.

Constructor

jsbeans.GMaps ( id , [options] )
Parameters:
id <String> A mandatory (but not used) identifier. it may be used for extra check, for example for map container emptyness.
[options] <JSON> See options property. Optional.

Properties

id - String

A required String usually representing the id of the map container.
Should be unique.

jsbeans.GMaps.ALREADY_LOADED - static Boolean

Says if a {@method} load has been already made to avoid loading Google Maps APIs™ twice.
Default Value: false

jsbeans.GMaps.ERROR - static final String

Instance {@property} status is set to jsbeans.GMaps.ERROR when script are NOT loaded (e.g. connection lost)!
Default Value: "ERROR"

jsbeans.GMaps.LOADING - static final String

Instance {@property} status is set to jsbeans.GMaps.LOADING between the invocation of {@method} load and the script load.
Default Value: "LOADING"

jsbeans.GMaps.NONE - static final String

Instance {@property} status is set to jsbeans.GMaps.NONE as first status, when no calls have been made, yet.
Default Value: "NONE"

jsbeans.GMaps.READY - static final String

Instance {@property} status is set to jsbeans.GMaps.READY when everything works fine!
Default Value: "READY"

options - JSON

Generic options container. See details for defaults.
Apart from defaults developer may set any other key/value pair as they will be sent to Google as request parameters. So if developer want to specify some other parameter, the version for example, this is the right place (for version: {v: 3.7}).

options.language - String

Language of map and controls. Default to en_US.
May be any of accepted language by Google. Example: {language: "it"} so "it_ALL" will be loaded.

options.libraries - Array

Google libraries to load. Default to ["places"].

options.onerror - Function

Callback function invoked in case of error. Default to empty.

options.sensor - boolean

Tells browser to retrieve current position (may be unoccurate due to ISP/wifi/3G connection). Default to true.

options.timeout - Integer

Sets the number of milliseconds to wait before checking if script has been loaded.

status - String

A String representing the status of current loading APIs.
May be one of: jsbeans.GMaps.NONE, jsbeans.GMaps.ERROR, jsbeans.GMaps.LOADING, jsbeans.GMaps.READY

Methods

load

void load ( )
Loads Google Maps APIs on page appending the right script tag on head. It uses the {@param} options to send parameters to server.
Returns: void

reset

static void reset ( [remove] )
Resets {@property} jsbeans.GMaps.ALREADY_LOADED to false so {@method} load may be called again.
Plaese, note that Google warns you not to load its script twice to avoid unexpected behaviour. You may force script removing by passing {@param} remove as true.
Parameters:
[remove] <Boolean> If true will try to remove Google script from page. Optional.
Returns: void


Copyright © 2016 Francesco Mele. All rights reserved.