166 lines
5.3 KiB
HTML
166 lines
5.3 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>gmaps.controls.js - Documentation</title>
|
|
|
|
<script src="scripts/prettify/prettify.js"></script>
|
|
<script src="scripts/prettify/lang-css.js"></script>
|
|
<!--[if lt IE 9]>
|
|
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
<![endif]-->
|
|
<link type="text/css" rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
|
|
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
|
|
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
|
|
</head>
|
|
<body>
|
|
|
|
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
|
|
<label for="nav-trigger" class="navicon-button x">
|
|
<div class="navicon"></div>
|
|
</label>
|
|
|
|
<label for="nav-trigger" class="overlay"></label>
|
|
|
|
<nav>
|
|
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="GMaps.html">GMaps</a><ul class='methods'><li data-type='method'><a href="GMaps.html#addControl">addControl</a></li><li data-type='method'><a href="GMaps.html#fitLatLngBounds">fitLatLngBounds</a></li><li data-type='method'><a href="GMaps.html#fitZoom">fitZoom</a></li><li data-type='method'><a href="GMaps.html#getElement">getElement</a></li><li data-type='method'><a href="GMaps.html#hideContextMenu">hideContextMenu</a></li><li data-type='method'><a href="GMaps.html#refresh">refresh</a></li><li data-type='method'><a href="GMaps.html#removeControl">removeControl</a></li><li data-type='method'><a href="GMaps.html#setCenter">setCenter</a></li><li data-type='method'><a href="GMaps.html#setContextMenu">setContextMenu</a></li><li data-type='method'><a href="GMaps.html#zoomIn">zoomIn</a></li><li data-type='method'><a href="GMaps.html#zoomOut">zoomOut</a></li></ul></li></ul>
|
|
</nav>
|
|
|
|
<div id="main">
|
|
|
|
<h1 class="page-title">gmaps.controls.js</h1>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<section>
|
|
<article>
|
|
<pre class="prettyprint source linenums"><code>GMaps.prototype.createControl = function(options) {
|
|
var control = document.createElement('div');
|
|
|
|
control.style.cursor = 'pointer';
|
|
|
|
if (options.disableDefaultStyles !== true) {
|
|
control.style.fontFamily = 'Roboto, Arial, sans-serif';
|
|
control.style.fontSize = '11px';
|
|
control.style.boxShadow = 'rgba(0, 0, 0, 0.298039) 0px 1px 4px -1px';
|
|
}
|
|
|
|
for (var option in options.style) {
|
|
control.style[option] = options.style[option];
|
|
}
|
|
|
|
if (options.id) {
|
|
control.id = options.id;
|
|
}
|
|
|
|
if (options.title) {
|
|
control.title = options.title;
|
|
}
|
|
|
|
if (options.classes) {
|
|
control.className = options.classes;
|
|
}
|
|
|
|
if (options.content) {
|
|
if (typeof options.content === 'string') {
|
|
control.innerHTML = options.content;
|
|
}
|
|
else if (options.content instanceof HTMLElement) {
|
|
control.appendChild(options.content);
|
|
}
|
|
}
|
|
|
|
if (options.position) {
|
|
control.position = google.maps.ControlPosition[options.position.toUpperCase()];
|
|
}
|
|
|
|
for (var ev in options.events) {
|
|
(function(object, name) {
|
|
google.maps.event.addDomListener(object, name, function(){
|
|
options.events[name].apply(this, [this]);
|
|
});
|
|
})(control, ev);
|
|
}
|
|
|
|
control.index = 1;
|
|
|
|
return control;
|
|
};
|
|
|
|
/**
|
|
* Add a custom control to the map UI.
|
|
*
|
|
* @param {object} options - 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`](https://developers.google.com/maps/documentation/javascript/controls#ControlPositioning) 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 {HTMLElement}
|
|
*/
|
|
GMaps.prototype.addControl = function(options) {
|
|
var control = this.createControl(options);
|
|
|
|
this.controls.push(control);
|
|
this.map.controls[control.position].push(control);
|
|
|
|
return control;
|
|
};
|
|
|
|
/**
|
|
* Remove a control from the map. `control` should be a control returned by `addControl()`.
|
|
*
|
|
* @param {HTMLElement} control - One of the controls returned by `addControl()`.
|
|
* @returns {HTMLElement} the removed control.
|
|
*/
|
|
GMaps.prototype.removeControl = function(control) {
|
|
var position = null,
|
|
i;
|
|
|
|
for (i = 0; i < this.controls.length; i++) {
|
|
if (this.controls[i] == control) {
|
|
position = this.controls[i].position;
|
|
this.controls.splice(i, 1);
|
|
}
|
|
}
|
|
|
|
if (position) {
|
|
for (i = 0; i < this.map.controls.length; i++) {
|
|
var controlsForPosition = this.map.controls[control.position];
|
|
|
|
if (controlsForPosition.getAt(i) == control) {
|
|
controlsForPosition.removeAt(i);
|
|
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
return control;
|
|
};
|
|
</code></pre>
|
|
</article>
|
|
</section>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<br class="clear">
|
|
|
|
<footer>
|
|
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Sun Apr 03 2016 18:36:23 GMT-0400 (EDT) using the Minami theme.
|
|
</footer>
|
|
|
|
<script>prettyPrint();</script>
|
|
<script src="scripts/linenumber.js"></script>
|
|
</body>
|
|
</html>
|