# GMaps

GMaps

## Constructor

#### new GMaps(options)

Source:
  - gmaps.core.js, line 152

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:
  - gmaps.core.js, line 242

Collection of custom controls in the map UI

##### Type:

- array

#### el :HTMLElement

Source:
  - gmaps.core.js, line 222

Container element

##### Type:

- HTMLElement

#### layers :array

Source:
  - gmaps.core.js, line 254

Collection of KML/GeoRSS and FusionTable layers

##### Type:

- array

#### map :google.maps.Map

Source:
  - gmaps.core.js, line 323

Google Maps map instance

##### Type:

- google.maps.Map

#### markerClusterer :object

Source:
  - gmaps.core.js, line 331

Marker Clusterer instance

##### Type:

- object

#### markers :array

Source:
  - gmaps.core.js, line 266

Collection of map's markers

##### Type:

- array

#### overlays :array

Source:
  - gmaps.core.js, line 248

Collection of map's overlays

##### Type:

- array

#### polygons :array

Source:
  - gmaps.core.js, line 284

Collection of map's polygons

##### Type:

- array

#### polylines :array

Source:
  - gmaps.core.js, line 272

Collection of map's lines

##### Type:

- array

#### routes :array

Source:
  - gmaps.core.js, line 278

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

##### Type:

- array

#### singleLayers :object

Source:
  - gmaps.core.js, line 260

Collection of data layers (See GMaps#addLayer)

##### Type:

- object

#### zoom :number

Source:
  - gmaps.core.js, line 292

Current map's zoom

##### Type:

- number

### Methods

#### addControl(options) → {HTMLElement}

Source:
  - gmaps.controls.js, line 67

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:
  - gmaps.core.js, line 539

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:
  - gmaps.core.js, line 520

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

#### getElement() → {HTMLElement}

Source:
  - gmaps.core.js, line 571

Return the HTML element container of the map.

##### Returns:

the element container.

Type
  HTMLElement

#### hideContextMenu()

Source:
  - gmaps.core.js, line 461

Hide the current context menu

#### refresh()

Source:
  - gmaps.core.js, line 513

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:
  - gmaps.controls.js, line 82

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:
  - gmaps.core.js, line 558

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:
  - gmaps.core.js, line 417

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:
  - gmaps.core.js, line 580

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:
  - gmaps.core.js, line 592

Decrease the map's zoom.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`magnitude` | number | <optional> | The number of times the map will be zoomed out.