GMaps

GMaps

GMaps

Constructor

new GMaps(options)

Source:

Creates a new GMaps instance, including a Google Maps map.

Parameters:
Name Type Description
options object

options accepts all the MapOptions and events listed in the Google Maps API. Also accepts:

  • lat (number): Latitude of the map's center
  • lng (number): Longitude of the map's center
  • el (string or HTMLElement): container where the map will be rendered
  • markerClusterer (function): A function to create a marker cluster. You can use MarkerClusterer or MarkerClustererPlus.

Members

controls :array

Source:

Collection of custom controls in the map UI

Type:
  • array

el :HTMLElement

Source:

Container element

Type:
  • HTMLElement

layers :array

Source:

Collection of KML/GeoRSS and FusionTable layers

Type:
  • array

map :google.maps.Map

Source:

Google Maps map instance

Type:
  • google.maps.Map

markerClusterer :object

Source:

Marker Clusterer instance

Type:
  • object

markers :array

Source:

Collection of map's markers

Type:
  • array

overlays :array

Source:

Collection of map's overlays

Type:
  • array

polygons :array

Source:

Collection of map's polygons

Type:
  • array

polylines :array

Source:

Collection of map's lines

Type:
  • array

routes :array

Source:

Collection of map's routes requested by GMaps#getRoutes, GMaps#renderRoute, GMaps#drawRoute, GMaps#travelRoute or GMaps#drawSteppedRoute

Type:
  • array

singleLayers :object

Source:

Collection of data layers (See GMaps#addLayer)

Type:
  • object

zoom :number

Source:

Current map's zoom

Type:
  • number

Methods

addControl(options) → {HTMLElement}

Source:

Add a custom control to the map UI.

Parameters:
Name Type Description
options object

The options object should contain:

  • style (object): The keys and values of this object should be valid CSS properties and values.
  • id (string): The HTML id for the custom control.
  • classes (string): A string containing all the HTML classes for the custom control.
  • content (string or HTML element): The content of the custom control.
  • position (string): Any valid google.maps.ControlPosition value, in lower or upper case.
  • events (object): The keys of this object should be valid DOM events. The values should be functions.
  • disableDefaultStyles (boolean): If false, removes the default styles for the controls like font (family and size), and box shadow.
Returns:
Type
HTMLElement

fitLatLngBounds(latLngs)

Source:

Adjust the map zoom to include all the coordinates in the latLngs array.

Parameters:
Name Type Description
latLngs array

Collection of google.maps.LatLng objects.

fitZoom()

Source:

Adjust the map zoom to include all the markers added in the map.

getElement() → {HTMLElement}

Source:

Return the HTML element container of the map.

Returns:

the element container.

Type
HTMLElement

hideContextMenu()

Source:

Hide the current context menu

refresh()

Source:

Trigger a resize event, useful if you need to repaint the current map (for changes in the viewport or display / hide actions).

removeControl(control) → {HTMLElement}

Source:

Remove a control from the map. control should be a control returned by addControl().

Parameters:
Name Type Description
control HTMLElement

One of the controls returned by addControl().

Returns:

the removed control.

Type
HTMLElement

setCenter(lat, lng, callbackopt)

Source:

Center the map using the lat and lng coordinates.

Parameters:
Name Type Attributes Description
lat number

Latitude of the coordinate.

lng number

Longitude of the coordinate.

callback function <optional>

Callback that will be executed after the map is centered.

setContextMenu(options)

Source:

Add a context menu for a map or a marker.

Parameters:
Name Type Description
options object

The options object should contain:

  • control (string): Kind of control the context menu will be attached. Can be "map" or "marker".
  • options (array): A collection of context menu items:
    • title (string): Item's title shown in the context menu.
    • name (string): Item's identifier.
    • action (function): Function triggered after selecting the context menu item.

zoomIn(magnitudeopt)

Source:

Increase the map's zoom.

Parameters:
Name Type Attributes Description
magnitude number <optional>

The number of times the map will be zoomed in.

zoomOut(magnitudeopt)

Source:

Decrease the map's zoom.

Parameters:
Name Type Attributes Description
magnitude number <optional>

The number of times the map will be zoomed out.