153 lines
5.5 KiB
HTML
Executable File
153 lines
5.5 KiB
HTML
Executable File
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>JSDoc: Source: directives/map_controller.js</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="styles/prettify-tomorrow.css">
|
|
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div id="main">
|
|
|
|
<h1 class="page-title">Source: directives/map_controller.js</h1>
|
|
|
|
|
|
|
|
|
|
|
|
<section>
|
|
<article>
|
|
<pre class="prettyprint source linenums"><code>/**
|
|
* @ngdoc directive
|
|
* @name MapController
|
|
* @requires $scope
|
|
* @property {Hash} controls collection of Controls initiated within `map` directive
|
|
* @property {Hash} markersi collection of Markers initiated within `map` directive
|
|
* @property {Hash} shapes collection of shapes initiated within `map` directive
|
|
* @property {MarkerClusterer} markerClusterer MarkerClusterer initiated within `map` directive
|
|
*/
|
|
/*jshint -W089*/
|
|
ngMap.MapController = function() {
|
|
|
|
this.map = null;
|
|
this._objects = [];
|
|
|
|
/**
|
|
* Add a marker to map and $scope.markers
|
|
* @memberof MapController
|
|
* @name addMarker
|
|
* @param {Marker} marker google map marker
|
|
*/
|
|
this.addMarker = function(marker) {
|
|
/**
|
|
* marker and shape are initialized before map is initialized
|
|
* so, collect _objects then will init. those when map is initialized
|
|
* However the case as in ng-repeat, we can directly add to map
|
|
*/
|
|
if (this.map) {
|
|
this.map.markers = this.map.markers || {};
|
|
marker.setMap(this.map);
|
|
if (marker.centered) {
|
|
this.map.setCenter(marker.position);
|
|
}
|
|
var len = Object.keys(this.map.markers).length;
|
|
this.map.markers[marker.id || len] = marker;
|
|
} else {
|
|
this._objects.push(marker);
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Add a shape to map and $scope.shapes
|
|
* @memberof MapController
|
|
* @name addShape
|
|
* @param {Shape} shape google map shape
|
|
*/
|
|
this.addShape = function(shape) {
|
|
if (this.map) {
|
|
this.map.shapes = this.map.shapes || {};
|
|
shape.setMap(this.map);
|
|
var len = Object.keys(this.map.shapes).length;
|
|
this.map.shapes[shape.id || len] = shape;
|
|
} else {
|
|
this._objects.push(shape);
|
|
}
|
|
};
|
|
|
|
this.addObject = function(groupName, obj) {
|
|
if (this.map) {
|
|
this.map[groupName] = this.map[groupName] || {};
|
|
var len = Object.keys(this.map[groupName]).length;
|
|
this.map[groupName][obj.id || len] = obj;
|
|
if (groupName != "infoWindows" && obj.setMap) { //infoWindow.setMap works like infoWindow.open
|
|
obj.setMap(this.map);
|
|
}
|
|
} else {
|
|
obj.groupName = groupName;
|
|
this._objects.push(obj);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Add a shape to map and $scope.shapes
|
|
* @memberof MapController
|
|
* @name addShape
|
|
* @param {Shape} shape google map shape
|
|
*/
|
|
this.addObjects = function(objects) {
|
|
for (var i=0; i<objects.length; i++) {
|
|
var obj=objects[i];
|
|
if (obj instanceof google.maps.Marker) {
|
|
this.addMarker(obj);
|
|
} else if (obj instanceof google.maps.Circle ||
|
|
obj instanceof google.maps.Polygon ||
|
|
obj instanceof google.maps.Polyline ||
|
|
obj instanceof google.maps.Rectangle ||
|
|
obj instanceof google.maps.GroundOverlay) {
|
|
this.addShape(obj);
|
|
} else {
|
|
this.addObject(obj.groupName, obj);
|
|
}
|
|
}
|
|
};
|
|
|
|
};
|
|
</code></pre>
|
|
</article>
|
|
</section>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<nav>
|
|
<h2><a href="index.html">Index</a></h2><h3>service</h3><ul><li><a href="Attr2Options.html">Attr2Options</a></li><li><a href="GeoCoder.html">GeoCoder</a></li><li><a href="NavigatorGeolocation.html">NavigatorGeolocation</a></li><li><a href="StreetView.html">StreetView</a></li></ul><h3>directive</h3><ul><li><a href="bicycling-layer.html">bicycling-layer</a></li><li><a href="cloud-layer.html">cloud-layer</a></li><li><a href="custom-control.html">custom-control</a></li><li><a href="drawing-manager.html">drawing-manager</a></li><li><a href="dynamic-maps-engine-layer.html">dynamic-maps-engine-layer</a></li><li><a href="fusion-tables-layer.html">fusion-tables-layer</a></li><li><a href="heatmap-layer.html">heatmap-layer</a></li><li><a href="info-window.html">info-window</a></li><li><a href="kml-layer.html">kml-layer</a></li><li><a href="lazy-load.html">lazy-load</a></li><li><a href="map.html">map</a></li><li><a href="map-data.html">map-data</a></li><li><a href="map-type.html">map-type</a></li><li><a href="MapController.html">MapController</a></li><li><a href="maps-engine-layer.html">maps-engine-layer</a></li><li><a href="marker.html">marker</a></li><li><a href="overlay-map-type.html">overlay-map-type</a></li><li><a href="shape.html">shape</a></li><li><a href="traffic-layer.html">traffic-layer</a></li><li><a href="transit-layer.html">transit-layer</a></li><li><a href="weather-layer.html">weather-layer</a></li></ul>
|
|
</nav>
|
|
|
|
<br clear="both">
|
|
|
|
<footer>
|
|
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a>
|
|
and <a href="https://github.com/allenhwkim/angular-jsdoc">angular-jsdoc</a>
|
|
</footer>
|
|
|
|
<script> prettyPrint(); </script>
|
|
<script src="scripts/linenumber.js"> </script>
|
|
<script>
|
|
var href=window.location.href.match(/\/([^\/]+$)/)[1];
|
|
document.querySelector("nav a[href='"+href+"']").scrollIntoView(true);
|
|
if (window.location.hash == "")
|
|
document.querySelector("body").scrollIntoView(true);
|
|
</script>
|
|
</body>
|
|
</html>
|